Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16566

Plotly texttemplate appears to ignore actual string template

$
0
0

From this part of the documentation, I expected the following code to produce a bar graph, where each bars contain the corresponding text as per df['label']. Instead, each bar contains the string found in df['Foo']. How can I get the texttemplate to work properly, i.e., have each bar contain the text from df['label']?

>>> import plotly>>> import pandas as pd>>> import plotly.graph_objects as go>>> plotly.__version__ 5.17.0>>> df = pd.DataFrame(data={"Foo":['a','b','c'],'Bar':[2,5,10], 'label':['alpha','beta', 'charlie']})df        Foo     Bar     label    0   a       2       alpha    1   b       5       beta    2   c       10      charlie>>> bar = go.Bar(x=df['Foo'], y=df['Bar'], texttemplate ="%{label}")>>> go.Figure(data=bar)

enter image description here


Viewing all articles
Browse latest Browse all 16566

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>