[英]How to use respective colorbar when using facet_col with plotly.express?
[英]How to plot multiple facet_col in pyhthon using plotly.express
使用此页面作为参考,我编写了一些代码,可以生成您期望的 output。 要使用类别变量创建多个图表,请使用facet_col
。
重要提示:不建议将代码或数据作为图像发布。 不建议在图片中发布代码或数据,因为这对受访者来说工作量太大,他们会不愿意回答。 结果,您不会得到快速的答复。
import random
import pandas as pd
import numpy as np
np.random.seed(20210226)
genre_1 = random.choices(['Action','Drama','Biography'], k=100)
rating = [random.uniform(7.0, 9.0) for i in range(100)]
runtime = [random.randint(85, 180) for n in range(100)]
df = pd.DataFrame({'genre_1':genre_1, 'rating':rating,'runtime':runtime})
import plotly.express as px
fig = px.scatter(df, x="runtime", y="rating", color="genre_1", facet_col="genre_1",
category_orders={"genre_1": ["Action", "Drama", "Biography"]})
fig.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.