Closed johentsch closed 2 months ago
Hmm, just found out that the labels are actually exported: When I do fig.write("gantt.png")
(kaleido backend), I get
It's more likely a bug then, I guess?
@johentsch what environment are you running the example in? And what version of Plotly.js do you see if you hover over the Plotly logo in the modebar?
You question solves the problem: I was running the code in PyCharm Pro 2023.3.2 (233.13135.95) and Plotly.js is pointing to v2.12.0. When I run it in Jupyter Lab, I'm getting the correct result like you.
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for a while, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson
I have used Plotly 5.18.0 to create this Gantt chart to which I have added two rectangle shapes:
Both rectangles come with labels that are not being displayed, no matter how hard I try.
fig["layout"]["shapes"]
looks like this:I've spent a lot of time playing around with the options from the manual but Plotly is not treating me to displaying any desired label. Am I doing something wrong or is it a bug?
On a side note, since it might point to the solution of the problem, the small black rectangle is set to
showlegend=True
but it does not appear in the legend.Code to reproduce
```python import plotly.graph_objects as go figure = {'data': [{'fill': 'toself', 'fillcolor': 'rgb(103, 232, 249)', 'hoverinfo': 'name', 'legendgroup': 'rgb(103, 232, 249)', 'mode': 'none', 'name': '2', 'x': [-1.0, -0.0, -0.0, -1.0, -1.0, -7.0, -6.0, -6.0, -7.0, -7.0, -2.0, -1.0, -1.0, -2.0, -2.0, -4.0, -3.0, -3.0, -4.0, -4.0, -6.0, -5.0, -5.0, -6.0], 'y': [5.8, 5.8, 6.2, 6.2, None, 5.8, 5.8, 6.2, 6.2, None, 5.8, 5.8, 6.2, 6.2, None, 5.8, 5.8, 6.2, 6.2, None, 5.8, 5.8, 6.2, 6.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(120, 113, 108)', 'hoverinfo': 'name', 'legendgroup': 'rgb(120, 113, 108)', 'mode': 'none', 'name': 'b7 (7)', 'x': [-7.0, -6.0, -6.0, -7.0], 'y': [1.8, 1.8, 2.2, 2.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(134, 25, 143)', 'hoverinfo': 'name', 'legendgroup': 'rgb(134, 25, 143)', 'mode': 'none', 'name': 'b3 (3)', 'x': [-3.0, -2.5, -2.5, -3.0, -3.0, -5.0, -4.0, -4.0, -5.0, -5.0, -2.5, -2.0, -2.0, -2.5], 'y': [0.8, 0.8, 1.2, 1.2, None, 0.8, 0.8, 1.2, 1.2, None, 0.8, 0.8, 1.2, 1.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(192, 38, 211)', 'hoverinfo': 'name', 'legendgroup': 'rgb(192, 38, 211)', 'mode': 'none', 'name': '3 (#3)', 'x': [-0.0, 1.0, 1.0, -0.0], 'y': [7.8, 7.8, 8.2, 8.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(239, 68, 68)', 'hoverinfo': 'name', 'legendgroup': 'rgb(239, 68, 68)', 'mode': 'none', 'name': '4', 'x': [-2.0, -1.0, -1.0, -2.0, -2.0, -2.5, -2.0, -2.0, -2.5], 'y': [2.8, 2.8, 3.2, 3.2, None, 2.8, 2.8, 3.2, 3.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(250, 204, 21)', 'hoverinfo': 'name', 'legendgroup': 'rgb(250, 204, 21)', 'mode': 'none', 'name': 'b6 (6)', 'x': [-3.0, -2.5, -2.5, -3.0, -3.0, -2.5, -2.0, -2.0, -2.5, -2.5, -2.0, -1.0, -1.0, -2.0], 'y': [-0.2, -0.2, 0.2, 0.2, None, -0.2, -0.2, 0.2, 0.2, None, -0.2, -0.2, 0.2, 0.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(34, 197, 94)', 'hoverinfo': 'name', 'legendgroup': 'rgb(34, 197, 94)', 'mode': 'none', 'name': '1', 'x': [0.0, 0.0, 0.0, 0.0, 0.0, -5.0, -4.0, -4.0, -5.0, -5.0, -0.0, 1.0, 1.0, -0.0, -0.0, -2.5, -2.0, -2.0, -2.5, -2.5, -2.0, -1.0, -1.0, -2.0, -2.0, -3.0, -2.5, -2.5, -3.0], 'y': [6.8, 6.8, 7.2, 7.2, None, 3.8, 3.8, 4.2, 4.2, None, 3.8, 3.8, 4.2, 4.2, None, 3.8, 3.8, 4.2, 4.2, None, 3.8, 3.8, 4.2, 4.2, None, 3.8, 3.8, 4.2, 4.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(37, 99, 235)', 'hoverinfo': 'name', 'legendgroup': 'rgb(37, 99, 235)', 'mode': 'none', 'name': '7 (#7)', 'x': [-4.0, -3.0, -3.0, -4.0, -4.0, -6.0, -5.0, -5.0, -6.0, -6.0, -1.0, -0.0, -0.0, -1.0], 'y': [8.8, 8.8, 9.2, 9.2, None, 8.8, 8.8, 9.2, 9.2, None, 8.8, 8.8, 9.2, 9.2], 'type': 'scatter'}, {'fill': 'toself', 'fillcolor': 'rgb(76, 29, 149)', 'hoverinfo': 'name', 'legendgroup': 'rgb(76, 29, 149)', 'mode': 'none', 'name': '5', 'x': [-6.0, -5.0, -5.0, -6.0, -6.0, -5.0, -4.0, -4.0, -5.0, -5.0, -0.0, 1.0, 1.0, -0.0, -0.0, -1.0, -0.0, -0.0, -1.0, -1.0, -7.0, -6.0, -6.0, -7.0, -7.0, -4.0, -3.0, -3.0, -4.0], 'y': [4.8, 4.8, 5.2, 5.2, None, 4.8, 4.8, 5.2, 5.2, None, 4.8, 4.8, 5.2, 5.2, None, 4.8, 4.8, 5.2, 5.2, None, 4.8, 4.8, 5.2, 5.2, None, 4.8, 4.8, 5.2, 5.2], 'type': 'scatter'}, {'legendgroup': 'rgb(103, 232, 249)', 'marker': {'color': 'rgb(103, 232, 249)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['V', 'V', 'v', 'v', 'ii%65', 'ii%65', 'V', 'V', 'V', 'V'], 'x': [-1.0, -0.0, -7.0, -6.0, -2.0, -1.0, -4.0, -3.0, -6.0, -5.0], 'y': [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], 'type': 'scatter'}, {'legendgroup': 'rgb(120, 113, 108)', 'marker': {'color': 'rgb(120, 113, 108)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['v', 'v'], 'x': [-7.0, -6.0], 'y': [2, 2], 'type': 'scatter'}, {'legendgroup': 'rgb(134, 25, 143)', 'marker': {'color': 'rgb(134, 25, 143)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['VI', 'VI', 'i', 'i', 'iv65', 'iv65'], 'x': [-3.0, -2.5, -5.0, -4.0, -2.5, -2.0], 'y': [1, 1, 1, 1, 1, 1], 'type': 'scatter'}, {'legendgroup': 'rgb(192, 38, 211)', 'marker': {'color': 'rgb(192, 38, 211)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['I', 'I'], 'x': [-0.0, 1.0], 'y': [8, 8], 'type': 'scatter'}, {'legendgroup': 'rgb(239, 68, 68)', 'marker': {'color': 'rgb(239, 68, 68)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['ii%65', 'ii%65', 'iv65', 'iv65'], 'x': [-2.0, -1.0, -2.5, -2.0], 'y': [3, 3, 3, 3], 'type': 'scatter'}, {'legendgroup': 'rgb(250, 204, 21)', 'marker': {'color': 'rgb(250, 204, 21)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['VI', 'VI', 'iv65', 'iv65', 'ii%65', 'ii%65'], 'x': [-3.0, -2.5, -2.5, -2.0, -2.0, -1.0], 'y': [0, 0, 0, 0, 0, 0], 'type': 'scatter'}, {'legendgroup': 'rgb(34, 197, 94)', 'marker': {'color': 'rgb(34, 197, 94)', 'opacity': 0, 'size': 1}, 'mode': 'markers', 'name': '', 'showlegend': False, 'text': ['',
'',
'i',
'i',
'I',
'I',
'iv65',
'iv65',
'ii%65',
'ii%65',
'VI',
'VI'],
'x': [0.0, 0.0, -5.0, -4.0, -0.0, 1.0, -2.5, -2.0, -2.0, -1.0, -3.0, -2.5],
'y': [7, 7, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
'type': 'scatter'},
{'legendgroup': 'rgb(37, 99, 235)',
'marker': {'color': 'rgb(37, 99, 235)', 'opacity': 0, 'size': 1},
'mode': 'markers',
'name': '',
'showlegend': False,
'text': ['V', 'V', 'V', 'V', 'V', 'V'],
'x': [-4.0, -3.0, -6.0, -5.0, -1.0, -0.0],
'y': [9, 9, 9, 9, 9, 9],
'type': 'scatter'},
{'legendgroup': 'rgb(76, 29, 149)',
'marker': {'color': 'rgb(76, 29, 149)', 'opacity': 0, 'size': 1},
'mode': 'markers',
'name': '',
'showlegend': False,
'text': ['V', 'V', 'i', 'i', 'I', 'I', 'V', 'V', 'v', 'v', 'V', 'V'],
'x': [-6.0,
-5.0,
-5.0,
-4.0,
-0.0,
1.0,
-1.0,
-0.0,
-7.0,
-6.0,
-4.0,
-3.0],
'y': [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
'type': 'scatter'}],
'layout': {'height': 600,
'hovermode': 'x unified',
'showlegend': True,
'title': {'text': 'Gantt chart'},
'xaxis': {'rangeselector': {'buttons': [{'count': 7,
'label': '1w',
'step': 'day',
'stepmode': 'backward'},
{'count': 1, 'label': '1m', 'step': 'month', 'stepmode': 'backward'},
{'count': 6, 'label': '6m', 'step': 'month', 'stepmode': 'backward'},
{'count': 1, 'label': 'YTD', 'step': 'year', 'stepmode': 'todate'},
{'count': 1, 'label': '1y', 'step': 'year', 'stepmode': 'backward'},
{'step': 'all'}]},
'showgrid': True,
'zeroline': False},
'yaxis': {'autorange': False,
'range': [-1, 11],
'showgrid': True,
'ticktext': ['Eb', 'Bb', 'F', 'C', 'G', 'D', 'A', 'E', 'B', 'F#'],
'tickvals': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
'zeroline': False},
'template': {'data': {'histogram2dcontour': [{'type': 'histogram2dcontour',
'colorbar': {'outlinewidth': 0, 'ticks': ''},
'colorscale': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']]}],
'choropleth': [{'type': 'choropleth',
'colorbar': {'outlinewidth': 0, 'ticks': ''}}],
'histogram2d': [{'type': 'histogram2d',
'colorbar': {'outlinewidth': 0, 'ticks': ''},
'colorscale': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']]}],
'heatmap': [{'type': 'heatmap',
'colorbar': {'outlinewidth': 0, 'ticks': ''},
'colorscale': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']]}],
'heatmapgl': [{'type': 'heatmapgl',
'colorbar': {'outlinewidth': 0, 'ticks': ''},
'colorscale': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']]}],
'contourcarpet': [{'type': 'contourcarpet',
'colorbar': {'outlinewidth': 0, 'ticks': ''}}],
'contour': [{'type': 'contour',
'colorbar': {'outlinewidth': 0, 'ticks': ''},
'colorscale': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']]}],
'surface': [{'type': 'surface',
'colorbar': {'outlinewidth': 0, 'ticks': ''},
'colorscale': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']]}],
'mesh3d': [{'type': 'mesh3d',
'colorbar': {'outlinewidth': 0, 'ticks': ''}}],
'scatter': [{'fillpattern': {'fillmode': 'overlay',
'size': 10,
'solidity': 0.2},
'type': 'scatter'}],
'parcoords': [{'type': 'parcoords',
'line': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'scatterpolargl': [{'type': 'scatterpolargl',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'bar': [{'error_x': {'color': '#2a3f5f'},
'error_y': {'color': '#2a3f5f'},
'marker': {'line': {'color': '#E5ECF6', 'width': 0.5},
'pattern': {'fillmode': 'overlay', 'size': 10, 'solidity': 0.2}},
'type': 'bar'}],
'scattergeo': [{'type': 'scattergeo',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'scatterpolar': [{'type': 'scatterpolar',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'histogram': [{'marker': {'pattern': {'fillmode': 'overlay',
'size': 10,
'solidity': 0.2}},
'type': 'histogram'}],
'scattergl': [{'type': 'scattergl',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'scatter3d': [{'type': 'scatter3d',
'line': {'colorbar': {'outlinewidth': 0, 'ticks': ''}},
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'scattermapbox': [{'type': 'scattermapbox',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'scatterternary': [{'type': 'scatterternary',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'scattercarpet': [{'type': 'scattercarpet',
'marker': {'colorbar': {'outlinewidth': 0, 'ticks': ''}}}],
'carpet': [{'aaxis': {'endlinecolor': '#2a3f5f',
'gridcolor': 'white',
'linecolor': 'white',
'minorgridcolor': 'white',
'startlinecolor': '#2a3f5f'},
'baxis': {'endlinecolor': '#2a3f5f',
'gridcolor': 'white',
'linecolor': 'white',
'minorgridcolor': 'white',
'startlinecolor': '#2a3f5f'},
'type': 'carpet'}],
'table': [{'cells': {'fill': {'color': '#EBF0F8'},
'line': {'color': 'white'}},
'header': {'fill': {'color': '#C8D4E3'}, 'line': {'color': 'white'}},
'type': 'table'}],
'barpolar': [{'marker': {'line': {'color': '#E5ECF6', 'width': 0.5},
'pattern': {'fillmode': 'overlay', 'size': 10, 'solidity': 0.2}},
'type': 'barpolar'}],
'pie': [{'automargin': True, 'type': 'pie'}]},
'layout': {'autotypenumbers': 'strict',
'colorway': ['#636efa',
'#EF553B',
'#00cc96',
'#ab63fa',
'#FFA15A',
'#19d3f3',
'#FF6692',
'#B6E880',
'#FF97FF',
'#FECB52'],
'font': {'color': '#2a3f5f'},
'hovermode': 'closest',
'hoverlabel': {'align': 'left'},
'paper_bgcolor': 'white',
'plot_bgcolor': '#E5ECF6',
'polar': {'bgcolor': '#E5ECF6',
'angularaxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''},
'radialaxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''}},
'ternary': {'bgcolor': '#E5ECF6',
'aaxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''},
'baxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''},
'caxis': {'gridcolor': 'white', 'linecolor': 'white', 'ticks': ''}},
'coloraxis': {'colorbar': {'outlinewidth': 0, 'ticks': ''}},
'colorscale': {'sequential': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']],
'sequentialminus': [[0.0, '#0d0887'],
[0.1111111111111111, '#46039f'],
[0.2222222222222222, '#7201a8'],
[0.3333333333333333, '#9c179e'],
[0.4444444444444444, '#bd3786'],
[0.5555555555555556, '#d8576b'],
[0.6666666666666666, '#ed7953'],
[0.7777777777777778, '#fb9f3a'],
[0.8888888888888888, '#fdca26'],
[1.0, '#f0f921']],
'diverging': [[0, '#8e0152'],
[0.1, '#c51b7d'],
[0.2, '#de77ae'],
[0.3, '#f1b6da'],
[0.4, '#fde0ef'],
[0.5, '#f7f7f7'],
[0.6, '#e6f5d0'],
[0.7, '#b8e186'],
[0.8, '#7fbc41'],
[0.9, '#4d9221'],
[1, '#276419']]},
'xaxis': {'gridcolor': 'white',
'linecolor': 'white',
'ticks': '',
'title': {'standoff': 15},
'zerolinecolor': 'white',
'automargin': True,
'zerolinewidth': 2},
'yaxis': {'gridcolor': 'white',
'linecolor': 'white',
'ticks': '',
'title': {'standoff': 15},
'zerolinecolor': 'white',
'automargin': True,
'zerolinewidth': 2},
'scene': {'xaxis': {'backgroundcolor': '#E5ECF6',
'gridcolor': 'white',
'linecolor': 'white',
'showbackground': True,
'ticks': '',
'zerolinecolor': 'white',
'gridwidth': 2},
'yaxis': {'backgroundcolor': '#E5ECF6',
'gridcolor': 'white',
'linecolor': 'white',
'showbackground': True,
'ticks': '',
'zerolinecolor': 'white',
'gridwidth': 2},
'zaxis': {'backgroundcolor': '#E5ECF6',
'gridcolor': 'white',
'linecolor': 'white',
'showbackground': True,
'ticks': '',
'zerolinecolor': 'white',
'gridwidth': 2}},
'shapedefaults': {'line': {'color': '#2a3f5f'}},
'annotationdefaults': {'arrowcolor': '#2a3f5f',
'arrowhead': 0,
'arrowwidth': 1},
'geo': {'bgcolor': 'white',
'landcolor': '#E5ECF6',
'subunitcolor': 'white',
'showland': True,
'showlakes': True,
'lakecolor': 'white'},
'title': {'x': 0.05},
'mapbox': {'style': 'light'}}},
'shapes': [{'fillcolor': 'LightSalmon',
'label': {'text': 'G/g', 'textposition': 'top left'},
'layer': 'below',
'line': {'width': 0},
'opacity': 0.5,
'type': 'rect',
'x0': -7.0,
'x1': 1.0,
'y0': -0.5,
'y1': 9.5},
{'label': {'font': {'color': 'black', 'size': 20},
'text': 'Keys of G or g',
'textposition': 'top left'},
'showlegend': True,
'type': 'rect',
'x0': -4,
'x1': -2,
'y0': 3,
'y1': 1}],
'legend': {'traceorder': 'grouped'}}}
fig = go.Figure(figure)
fig.show()
```