Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove Data from X Axis Labels plotly

enter image description hereIs there a way to remove the x axis data from the x axis? I need the labels, just not the data/volume. (i.e display "Example A", not "Example A 7000")

labels = ["Example A","Example B","Example C","Example D","Example E","Example F","Example G","Example H","Example I","Example J","Example K","Example L","Example M","Example N","Example O","Example P","Example Q","Example R","Example S","Example T",]
widths = np.array([7000,5000,4000,4000,3000,2000,2000,2000,2000,1800,1700,1500,1300,1200,1200,1100,1000,1000,1000,1000,])
data = { "5": [20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20],
"4": [20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20],
"3": [20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20],
"2": [20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20],
"1": [20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20],}
fig = go.Figure()
for key in data:
fig.add_trace(go.Bar(
    name=key,
    y=data[key],
    x=np.cumsum(widths)-widths,
    width=widths,
    customdata=np.transpose([labels]),
    textposition="inside",
    insidetextanchor = "middle",
fig.update_xaxes(
tickvals=np.cumsum(widths)-widths/2,
ticktext= ["%s<br>%d" % (l, w) for l, w in zip(labels, widths)])
fig.update_layout(
barmode="stack",
uniformtext=dict(mode="hide", minsize=18),
height = 1000,
width = 2000,)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You’re explicitly including the widths as labels in this line:

["%s<br>%d" % (l, w) for l, w in zip(labels, widths)]

Change that to:

["%s" % l for l in labels]

And it should work

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading