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):标题
"""
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")