python - 绘制子图分组 x 轴
问题描述
我在 x 轴上有一个带有不同组的箱线图的子图。我想为 x 轴上的不同组而不是不同的子图使用相同的颜色。怎么做?
x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1',
'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2',
'day 3', 'day 3', 'day 3', 'day 3', 'day 3', 'day 3']
cat = go.Box(
x=x,
y=np.random.randn(18)-1,
name='cat',
marker=dict(
outliercolor='rgba(255,0,0,0)'
)
)
dog = go.Box(
x=x,
y=np.random.randn(18)*1000,
name='dog',
marker=dict(
outliercolor='rgba(255,0,0,250)'
)
)
fig = tools.make_subplots(rows=1, cols=2)
fig.append_trace(cat, 1, 1)
fig.append_trace(dog, 1, 2)
fig['layout'].update(height=600, width=1000, title='cats and dogs day1-3')
py.iplot(fig, filename='simple-subplot-with-annotations')
或者,我可以将所有轨迹添加到一个list
-type 变量中,为每个组(即第 1 天、第 2 天、第 3 天)创建不同的颜色,但是每个组的 y 轴刻度是如此不同,这会使我的情节不清楚1 种类型的迹线(即,cat
与 相比,值范围要低得多dog
)。
解决方案
推荐阅读
- node.js - node.js是什么导致错误400错误请求
- javascript - 如何仅使用每个对象的银行账户号码将钱从银行账户对象转移到另一个银行账户对象?
- javascript - Webpack:将多个 HTML 文件放入多个目录
- r - R:在 tibble 列中使用 strsplit
- javascript - 试图将我的 api 调用从 App.js 移动到操作文件
- python - 将打印输出保存为 dict 或 JSON
- reactjs - 如何禁用 ReactJS 中特定输入的选项卡按钮?
- javascript - jquery forEach 函数用于显示/列出动态元素
- .htaccess - htaccess 重写规则与条件和重写
- python - Updated-leetcode 实现 atoi 函数,对特定输出给出错误结果