adding annotation to a plot #99
-
I'm having trouble converting my python annotation on taipy.
I have try something like this without any success:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, Thank you for your question! You almost have the correct syntax. What has to be passed to the layout is a Python dictionary. Here is how you define the dictionary: test_anot = {
"showlegend":True,
"annotations": [
{
"x": 0.25,
"y": 0.5,
"xref": 'paper',
"yref": 'paper',
"text": traitement_std,
"showarrow": False,
"align":'left'
}
]
} I have also added
Now, the code should work. You can find below the full code ready-to-use: import pandas as pd
from taipy.gui import Gui
dataset = pd.DataFrame({"Wavelenght (nm)": range(1,11),
"Intensity": [7,4,24,14,15,3,7,4,12,10]})
traitement_std = 'λ mean: {:.1f} nm <br>λ peak: {:.1f} nm <br>Δλ: {:.1f} nm'.format(5,4,3)
test_anot = {
"showlegend":True,
"annotations": [
{
"x": 0.25,
"y": 0.5,
"xref": 'paper',
"yref": 'paper',
"text": traitement_std,
"showarrow": False,
"align":'left'
}
]
}
# Definition of the page
page = "<|{dataset}|chart|x=Wavelenght (nm)|y=Intensity|layout={test_anot}|>"
Gui(page).run() I hope this is what you are looking for! |
Beta Was this translation helpful? Give feedback.
Hi,
Thank you for your question! You almost have the correct syntax. What has to be passed to the layout is a Python dictionary. Here is how you define the dictionary:
I have also added
"showlegend":True
. You can find other options for annotations and text here. The Javascript dictionary has to be translated into a Python dictionary. And here is how you pass it to Taipy:<|{dataset}|chart|x=Wavelenght (nm)|y=Intensity|layout={test_anot}|>
Now, the code should work.…