0

I have started from the following example:

from plotly.subplots import make_subplots
from plotly import graph_objects as go

fig = make_subplots(rows=3, cols=1, subplot_titles=["foo", "bar", "goo"])

for i in range(3):
    fig.add_trace(go.Box(x=list(range(100)), boxmean="sd", showlegend=False), row=i + 1, col=1)

fig.update_layout(height=600, width=1200, title_text="Yo Yo")
fig

It yields three box plots in three rows of a subplots Plotly container:

enter image description here

My objective is:

  1. Get rid of the trace X strings on the left.
  2. Use the same color for all three subplots.

By using:

fig.add_trace(go.Box(x=list(range(100)), boxmean="sd", showlegend=False, fillcolor="blue"), row=i + 1, col=1)

I'm getting closer to the second objective, but it is not yet there:

enter image description here

I'm guessing I can ask for a color cycle consisting of a single color; but I didn't manage to do that.

Dror
  • 12,174
  • 21
  • 90
  • 160
  • FWIW, here's another question I had related to the same bigger challenge I have: https://stackoverflow.com/q/72110582/671013 – Dror May 04 '22 at 09:20

1 Answers1

0

We have already tried the fill and obtained results, so I think the remaining task is to align the line colors. The y-axis labels can be set to empty by name. There are other ways to do this, but I think this is the easiest.

from plotly.subplots import make_subplots
from plotly import graph_objects as go

fig = make_subplots(rows=3, cols=1, subplot_titles=["foo", "bar", "goo"])

for i in range(3):
    fig.add_trace(go.Box(x=list(range(100)),
                         boxmean="sd",
                         fillcolor='blue',
                         line={'color':'red'},
                         name='',
                         showlegend=False), row=i + 1, col=1)

fig.update_layout(height=600, width=1200, title_text="Yo Yo")
fig.show()

enter image description here

r-beginners
  • 31,170
  • 3
  • 14
  • 32