Plotly.express 常用参数
color_continuous_scale #使用连续性颜色
color_continuous_midpoint #连续性颜色的中间基准点颜色
color_discrete_map #使用离散型颜色
hover_name # 鼠标悬浮时,信息栏的名称;
hover_data # 鼠标悬浮时,信息栏显示的信息
labels={'x':'x','y':'cos(x)',column_name:False} # 设置XY轴标题;
line_group # 线条分组的依据;
points #'outliers','all','False','suspectoutliers' 条形图bar是否要显示点,以及点的类型
title # 图片标题;
width, height, #设置图片的宽度和长度 默认为 autosize
orientation #'v','h'条形图的方向
Plotly.graph_objects 常用参数
Trace 参数
go.Table(
columwidth, #每列的宽度
header=dict(values, #标题栏
line_color, #线条颜色
fill_color, #背景填充色
align, #'left','center','right'文字对齐方向
height, #每列的高度
font=dict(family,size,color)
),
cells=dict(values, #每一列的值
line_color,fill_color,align,
)
)
boxmean #True,'sd'箱式图box中是否显示平均值
boxpoints #和px中的points类似,False,'outliers','suspectoutliers'
jitter #将点散开后的宽度
connectgaps:True, False:是否将缺失的点也连接起来
error_y=dict(type, #'data','percent','constant',下面的误差数值是绝对值还是百分比
array, # Y的(正向)误差值(为数组)
arrayminus, # Y的负向误差(为数组)
value,valueminus #同array和arrayminus,标量
visible, #误差条是否可见
symmetric, #误差条是否对称
color,width,thickness,
)
hovertext # 鼠标悬浮时显示的信息
hole # 饼图中用于设置空心半径
insidetextorientation #'radial'饼状图,旭日图内的文字方向
mode='markers+lines+text': # 显示点还是线
line = dict(color,width) # 设置line 的属性
line_dash: # 'dash' 虚线, 'dot' 点;
marker=dict(size,color,line_width,line_color,
colorscale, #使用的色系
showscale, #是否在旁边显示颜色条
opacity, #标记符号的不透明度
symbol, # 标记的符号类型
)
name: #该 trace 的名字,用于显示分类;
opacity #不透明度
title #图像的标题
text #鼠标悬浮式显示的信息;
textinfo #'percent','label','name','percent parent','percent root'可多选,使用+进行组合
textposition # 'auto','inside','outside','top(middle,bottom) left(center,right)'信息显示位置
go.Violin(box_visible #True, False, 中间是否显示箱式图
meanline_visible #是否显示平均值
legendgroup # 分组凭据
side #'negative''positive'显示violin的哪一半
orientation # 'h''v'violin的方向
)
Layout 参数
autosize # 图片大小是否为自动调整
width,height, #绘制图像的尺寸
barmode #'group','stack','overlay'设置bar显示模式
bargap,bargroupgap #条形图之间的间隔
boxmode #和barmode类似
hovermode #'closest',‘x’‘y’"x unified""y unified"鼠标悬停时,显示悬停信息的方式
hoverlabel_align #'right','left','center' hoverdata 的对其方式
margin=dict(t,b,l,r) # 图片周围的 margin
plot_bgcolor # 'white',设置背景色
showlegend # 是否显示图例
title_text # 图片标题
xaxis=dict(domain #[]范围,表示X轴在整个图像中的比例
autorange, # X轴的刻度范围是否自动调节
gridwidth, #网格线的粗度
showline, #是否显示坐标轴横线
showgrid, #是否显示网格
showticklabels, #是否显示刻度线
linecolor, linewidth,
dtick, #相邻刻度线间隔
ticks='inside','outside','auto' # 刻度是坐标轴内/外部
tickfont, # 刻度字体样式
title_text, # X轴标题
type, #'log'‘linear’,'category','date'X轴的显示方式
xaxis_tickangle, # X 轴文本标签旋转角度(顺时针为正值)
zeroline, #是否显示0刻度线
zerolinecolor,zerolinewidth,
)
legend=dict(font_size #图例字体
yanchor,xanchor, #'middle','right','left'图例框以左侧(右侧中间)为基准点
)
violinmode #'overlay','group'多个violin叠加到一起还是分组
violingap #不同violin之间的间距
violingroupgap #不同violin分组之间的间距
fig.update_xaxes()
和fig.update_yaxes()
常用参数:这两个函数的参数作用几乎相同
fig = go.Figure()
fig.update_xaxes(
title # dict() 自定义 XY 轴标题的 text,color 等属性
tickprefix # string, 刻度线前缀
showgrid # True,False,是否显示网格线
matches # 'x','y','None'有多个子图时,改变其中一个的x轴范围,其他的也会随之改变
secondary_y # True,False 是否绘制第二个Y轴 只有`update_yaxes()`有这个属性
range # XY的刻度范围
autorange # 是否自动调整范围
type # string,"log""category""date""linear" XY轴刻度的显示模式
col,row # 在多子图中指定所要修改的子图位置
)
fig.add_shape()
向图像上添加“线”“圆”“矩形”等
fig = go.Figure()
fig.add_shape(
type, # string,'line''circle''rect' 定义要添加的图形
line, # dict,自定义 line 的属性
)
fig.add_annotation()
向图像上添加“注释”
fig = go.Figure()
fig.add_annotation(
x,y # 注释的位置坐标
ax,ay # 注释的实际位置与指定坐标的偏差
text # 注释内容
showarrow # 是否显示箭头
xanchor #'left','right','center'以注释框的左边(左边中间)为基准进行定位
yanchor #top,bottom,middle 基本和 xanchor相同
textangle # 注释框旋转角度
opacity #float,[0,1] 不透明度
)
常用颜色
‘firebrick’, ‘royalblue’, ‘darkslategray’, ‘grey, ‘lightgrey’, ‘white’, ‘black’, 'indianred', 'lightseagreen', ‘Viridis’,