Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用plotly express创建子地块?_Python_Plotly - Fatal编程技术网

Python 如何使用plotly express创建子地块?

Python 如何使用plotly express创建子地块?,python,plotly,Python,Plotly,一直喜欢plotly express图形,但现在想用它们创建一个仪表板。找不到有关此的任何文档。这可能吗?来自文档: **facet_row** (string: name of column in data_frame) Values from this column are used to assign marks to facetted subplots in the vertical direction. **facet_col** (string: name of column in

一直喜欢plotly express图形,但现在想用它们创建一个仪表板。找不到有关此的任何文档。这可能吗?

来自文档:

**facet_row**
(string: name of column in data_frame) Values from this column are used to assign marks to facetted subplots in the vertical direction.
**facet_col**
(string: name of column in data_frame) Values from this column are used to assign marks to facetted subplots in the horizontal direction.
这里也有一些例子


不幸的是,现在还没有。请参阅以下问题以获得更新:

我也在努力寻找对此的回应,并最终创建了自己的解决方案(请参阅此处的完整分解:)

本质上,“make_subplot()”接受的是轨迹,而不是Express返回的图形,因此在Express中创建图形后,您可以分解其轨迹,然后将其重新组合成子地块

代码: 输出:

谢谢你的帮助。刻面_行允许使用有用的面板,但对于不同的线段,它们通常是相同的视图(例如)。我希望将几个不相关的视图合并到仪表板中。这里有详细的例子供参考。最后一行中的dcc是什么?@SamMurphy抱歉,这是一个虚线核心组件,我将此图与Plotly Dash一起使用,因此在我的示例中,我将返回该图作为虚线图对象。最终的图形
这个图形应该可以很好地保存所有的图形数据
import plotly.express as px
import plotly.subplots as sp

# Create figures in Express
figure1 = px.line(my_df)
figure2 = px.bar(my_df)

# For as many traces that exist per Express figure, get the traces from each plot and store them in an array.
# This is essentially breaking down the Express fig into it's traces
figure1_traces = []
figure2_traces = []
for trace in range(len(figure1["data"])):
    figure1_traces.append(figure1["data"][trace])
for trace in range(len(figure2["data"])):
    figure2_traces.append(figure2["data"][trace])

#Create a 1x2 subplot
this_figure = sp.make_subplots(rows=1, cols=2) 

# Get the Express fig broken down as traces and add the traces to the proper plot within in the subplot
for traces in figure1_traces:
    this_figure.append_trace(traces, row=1, col=1)
for traces in figure2_traces:
    this_figure.append_trace(traces, row=1, col=2)

#the subplot as shown in the above image
final_graph = dcc.Graph(figure=this_figure)