简体   繁体   English

plotly快递散plot python

[英]plotly express scatter plot python

I have a problem with plotly I want to make a scatter plot I want to make this same graph but with other circle shape for ind1, tringale for ind2 and the color is according to the type我有一个问题 plotly 我想做一个散点图 plot 我想做同样的图形,但是 ind1 的其他圆形,ind2 的 tringale 颜色根据类型

here is my my code code for your help:这是我的代码代码,供您帮助:

data = {'ind1':[4,8,12,13,22,23],'ind2':[1,5,9,60,90,30],'type':['reg1','reg2','reg1','reg1','reg2','reg1']}
df = pd.DataFrame(data=data)
fig = px.scatter(df, x=df['ind1'],y= df['ind2'],color='type')
fig.show() 

the graph that I compe to make and like the one in my answer but instead of having the shape of point in the two indicator I want to make the difference by changing the shape of the indicator 2 in triangle and keep the color by type like c is the case in this figure我努力制作并喜欢我的答案中的图表,但我不想在两个指标中具有点的形状,而是想通过改变三角形中的指标 2 的形状来产生差异,并按类型保持颜色,如 c是这个图的情况

在此处输入图像描述

I don't really understand how the desired graph should look like,我真的不明白所需的图形应该是什么样子,

but here is an example of styling symbols with plotly express但这里有一个带有 plotly express 的样式符号示例

Note, that in order for this to work you need to pass a list list_of_symbols to symbol variable (in this case it is the name of the column in df containting that list) and a dictionary dict with dict.keys() = list_of_symbols , while values for desired symbols you can look up here请注意,为了使其工作,您需要将列表list_of_symbols传递给symbol变量(在这种情况下,它是df中包含该列表的列的名称)和带有dict.keys() = list_of_symbols字典dict ,而您可以 在此处查找所需符号的值marker_size = 15 的示例图

data = {'ind1':[4,8,12,13,22,23],'ind2':[1,5,9,60,90,30],'type':['reg1','reg2','reg1','reg1','reg2','reg1']}
df = pd.DataFrame(data=data)
fig = px.scatter(df, x='ind1', y= 'ind2', color='type', 
                 symbol = 'ind2',
                 symbol_map = {1:'diamond-open-dot',
                               5:'diamond-open',
                               9:'diamond',
                               60:'cross-open-dot',
                               90:'triangle-right-open-dot',
                               30:'hexagon'})
fig.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM