[英]How to plot a boxplot using aggregates in plotly?
I need to plot a series of boxplots, based on results of numerical air quality model.我需要根据数值空气质量模型的结果绘制一系列箱线图。 Since this is a significant amount of data, I trigger calculation of aggregates (min, max, quartiles, etc.) every time when new model results become ready and store them in PostgreSQL.
由于这是大量数据,因此每当新模型结果准备就绪并将它们存储在 PostgreSQL 中时,我都会触发聚合计算(最小值、最大值、四分位数等)。 For visualization purpose I load the aggregates into pandas and I plot them using dash.
出于可视化目的,我将聚合加载到 Pandas 中,并使用破折号绘制它们。 I am able to plot line plots of timeseries, however I would like to get something like this example , but also interactive.
我能够绘制时间序列的线图,但是我想得到类似这个例子的东西,但也是交互式的。
As I went through plotly examples, it looks like it always require the raw data for ploting boxplots ( https://plot.ly/python/box-plots/#basic-box-plot ).当我查看情节示例时,看起来它总是需要原始数据来绘制箱线图( https://plot.ly/python/box-plots/#basic-box-plot )。 I really enjoy the concept of presentation and logic separation.
我真的很喜欢表示和逻辑分离的概念。 Is it possible to get a plotly box plot based on aggregated data?
是否有可能根据聚合数据获得一个情节箱线图?
You can provide your aggreate values to a Plotly boxplot in Python by providing it in the following format:您可以通过以下格式将聚合值提供给 Python 中的 Plotly 箱线图:
plotly.graph_objs.Box(y=[val_min,
val_lower_box,
val_lower_box,
val_median,
val_upper_box,
val_upper_box,
val_max])
eg例如
import plotly
plotly.offline.init_notebook_mode()
val_min = 1
val_lower_box = 2
val_median = 3
val_upper_box = 4.5
val_max = 6
box_plot = plotly.graph_objs.Box(y=[val_min,
val_lower_box,
val_lower_box,
val_median,
val_upper_box,
val_upper_box,
val_max])
plotly.offline.iplot([box_plot])
gives you给你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.