ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

plotly使用方法

2021-12-07 19:02:16  阅读:283  来源: 互联网

标签:title color 方法 fig plotly 使用 marker line data


plotly使用方法文档

常用的库

px的方法

import plotly.express as px
px.histogram(df, x="total_bill",  marginal="rug", # can be `box`, `violin`
                         hover_data=df.columns)
"""
Args:
	df(DataFrame or array-like or dict):输入数据
	x(str or int or Series or array-like):数据属性
	marginal(srt):If set, a subplot is drawn alongside the main plot, 可视化分布.
	hover_data(list of str or int, or Series or array-like, or dict):data_frame中列列表或pandas series,或		array_like对象或具有列名称的dict,值true(默认格式化)false(以便从鼠带信息删除此列)或格式化 字符串,例如“:.3f”或'|		%a'或list like数据,以显示在悬停工具提示或与bool或格式化字符串中的元组,以及列出的数据,以将悬停中作为第二个元素出现		在悬停中 来自这些列的值在HOVER TOOLTIP中显示为额外的数据。
"""
fig.update_layout(title_text='Distribution of Classes')
"""
Args:
	title_text(str):标题
"""

ff的方法

import plotly.figure_factory as ff
fig = ff.create_distplot([meta_train['R_avg'], meta_train['G_avg'], meta_train['B_avg']],group_labels=['R','G','B'],colors=['RED','GREEN','BLUE'])
fig.update_layout(showlegend=False, template='simple_white')
fig.update_layout(title_text = 'Distribution of Channel Values')
fig.data[0].marker.line.color = 'rgb(0,0,0)'
fig.data[0].marker.line.width = .5
fig.data[1].marker.line.color = 'rgb(0,0,0)'
fig.data[1].marker.line.width = .5
fig.data[2].marker.line.color = 'rgb(0,0,0)'
fig.data[2].marker.line.width = .5

GO的方法

import plotly.graph_objects as go
fig = go.Figure()

for idx, values in enumerate([meta_train['R_avg'], meta_train['G_avg'], meta_train['B_avg']]):
    if idx == 0:
        color = "RED"
    if idx == 1:
        color = "GREEN"
    if idx == 2:
        color = "BLUE"
    fig.add_trace(go.Box(x=[color]*len(values), y=values, name=color, marker=dict(color=color.lower())))
    
fig.update_layout(yaxis_title="Mean Value", xaxis_title="Color Channel",
                  title="Mean Value vs. Color Channel", template="plotly_white")

标签:title,color,方法,fig,plotly,使用,marker,line,data
来源: https://blog.csdn.net/y1040468929/article/details/121751068

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有