【Python百日进阶-数据分析】Day135 - plotly旭日图:px.sunburst()语法

一、语法

旭日形图将分层数据表示为分布在多个同心环级别上的扇区。

plotly.express.sunburst(data_frame=None, 
                        names=None, 
                        values=None, 
                        parents=None, 
                        path=None, 
                        ids=None, 
                        color=None, 
                        color_continuous_scale=None, 
                        range_color=None, 
                        color_continuous_midpoint=None, 
                        color_discrete_sequence=None, 
                        color_discrete_map=None, 
                        hover_name=None, 
                        hover_data=None, 
                        custom_data=None, 
                        labels=None, 
                        title=None, 
                        template=None, 
                        width=None, 
                        height=None, 
                        branchvalues=None, 
                        maxdepth=None)

二、参数

  • data_frame ( DataFrame或类似数组的或dict ) – 需要传递此参数才能使用列名(而不是关键字名)。Array-like 和 dict 在内部转换为 pandas DataFrame。可选:如果缺少,则使用其他参数在后台构建 DataFrame。

  • names (str或int或Series或array-like)- 中的列名称data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用作扇区的标签。

  • values ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于设置与扇区关联的值。

  • parents ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用作旭日形图和树状图中的父级。

  • path (str或int的列表,或Series或类似数组)-data_frame或 pandas Series 或 array_like 中的列名称列表定义扇区层次结构的矩形数据框的列名称或列,从根到叶。如果路径 AND ids 或 parents 被传递,则会引发错误

  • ids ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于设置扇区的 id

  • color (str或int或Series或array-like)– 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于为标记分配颜色。

  • color_continuous_scale ( list of str ) – 字符串应定义有效的 CSS-colors 此列表用于在由 表示的列color包含数字数据时构建连续的色标。子模块中提供了各种有用的色标 plotly.express.colors,特别 plotly.express.colors.sequential是plotly.express.colors.diverging 和plotly.express.colors.cyclical。

  • range_color(两个数字的列表)–如果提供,则覆盖连续色标上的自动缩放。

  • color_continuous_midpoint (number (default None)) – 如果设置,计算连续色标的边界以获得所需的中点。plotly.express.colors.diverging建议在使用色标作为 的输入 时设置此值 color_continuous_scale。

  • color_discrete_sequence ( list of str ) – 字符串应该定义有效的 CSS 颜色。当color设置为 且对应列中的值不是数字时,该列中的值通过color_discrete_sequence 按 中描述的顺序循环分配颜色category_orders,除非 的值 color是 中的键color_discrete_map。子模块中提供了各种有用的颜色序列plotly.express.colors,特别是plotly.express.colors.qualitative.

  • color_discrete_map(带有 str 键和 str 值的字典(默认{}))——字符串值应定义有效的 CSS-colors 用于覆盖 color_discrete_sequence以将特定颜色分配给与特定值对应的标记。中的键color_discrete_map应该是由 表示的列中的值color。或者,如果 的值color是有效颜色,则’identity’可以传递字符串以直接使用它们。

  • hover_name(str或int或Series或array-like)- 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值在悬停工具提示中以粗体显示。

  • hover_data ( list of str or int , or Series or array-like , or dict ) – 或者 pandas Series 中的列名列表data_frame,或者是 array_like 对象或者以列名作为键的 dict,值为 True (默认为格式)False(为了从悬停信息中删除此列)或格式字符串,例如 ‘:.3f’ 或 ’ | %a’ 或类似列表的数据出现在悬停工具提示中,或带有布尔或格式化字符串的元组作为第一个元素,以及类似列表的数据作为第二个元素出现在悬停中 这些列中的值在悬停工具提示中显示为额外数据.

  • custom_data(str或int的列表,或Series或类似数组)——data_frame或 pandas Series 或 array_like 对象中的列名称这些列的值是额外数据,例如用于小部件或 Dash 回调。此数据对用户不可见,但包含在图形发出的事件中(套索选择等)

  • labels (带有 str 键和 str 值的字典(默认{}))——默认情况下,列名在图中用于轴标题、图例条目和悬停。这个参数允许它被覆盖。此 dict 的键应对应于列名,值应对应于要显示的所需标签。

  • title ( str ) – 图形标题。

  • template (str或dict或plotly.graph_objects.layout.Template 实例)–图形模板名称(必须是 plotly.io.templates 中的键)或定义。

  • width (int (default None)) – 图形宽度(以像素为单位)。

  • height (int (default None)) – 以像素为单位的图形高度。

  • branchvalues ( str ) – ‘total’ 或 ‘remainder’ 确定其中的项目如何values相加。当设置为“total”时,其中的项目values被视为其所有后代的值。当设置为“剩余”时,values对应于根和分支的项目:扇区被视为额外部分,而不是其叶子值总和的一部分。

  • maxdepth ( int ) – 正整数 设置任何给定的渲染扇区数 level。设置maxdepth为 -1 以呈现层次结构中的所有级别。

  • data_frame (DataFrame or array-like or dict) – This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are tranformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constructed under the hood using the other arguments.

  • names (str or int or Series or array-like) – Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like are used as labels for sectors.

  • values (str or int or Series or array-like) – Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to set values associated to sectors.

  • parents (str or int or Series or array-like) – Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like are used as parents in sunburst and treemap charts.

  • path (list of str or int, or Series or array-like) – Either names of columns in data_frame, or pandas Series, or array_like objects List of columns names or columns of a rectangular dataframe defining the hierarchy of sectors, from root to leaves. An error is raised if path AND ids or parents is passed

  • ids (str or int or Series or array-like) – Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to set ids of sectors

  • color (str or int or Series or array-like) – Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to assign color to marks.

  • color_continuous_scale (list of str) – Strings should define valid CSS-colors This list is used to build a continuous color scale when the column denoted by color contains numeric data. Various useful color scales are available in the plotly.express.colors submodules, specifically plotly.express.colors.sequential, plotly.express.colors.diverging and plotly.express.colors.cyclical.

  • range_color (list of two numbers) – If provided, overrides auto-scaling on the continuous color scale.

  • color_continuous_midpoint (number (default None)) – If set, computes the bounds of the continuous color scale to have the desired midpoint. Setting this value is recommended when using plotly.express.colors.diverging color scales as the inputs to color_continuous_scale.

  • color_discrete_sequence (list of str) – Strings should define valid CSS-colors. When color is set and the values in the corresponding column are not numeric, values in that column are assigned colors by cycling through color_discrete_sequence in the order described in category_orders, unless the value of color is a key in color_discrete_map. Various useful color sequences are available in the plotly.express.colors submodules, specifically plotly.express.colors.qualitative.

  • color_discrete_map (dict with str keys and str values (default {})) – String values should define valid CSS-colors Used to override color_discrete_sequence to assign a specific colors to marks corresponding with specific values. Keys in color_discrete_map should be values in the column denoted by color. Alternatively, if the values of color are valid colors, the string ‘identity’ may be passed to cause them to be used directly.

  • hover_name (str or int or Series or array-like) – Either a name of a column in data_frame, or a pandas Series or array_like object. Values from this column or array_like appear in bold in the hover tooltip.

  • hover_data (list of str or int, or Series or array-like, or dict) – Either a list of names of columns in data_frame, or pandas Series, or array_like objects or a dict with column names as keys, with values True (for default formatting) False (in order to remove this column from hover information), or a formatting string, for example ‘:.3f’ or ‘|%a’ or list-like data to appear in the hover tooltip or tuples with a bool or formatting string as first element, and list-like data to appear in hover as second element Values from these columns appear as extra data in the hover tooltip.

  • custom_data (list of str or int, or Series or array-like) – Either names of columns in data_frame, or pandas Series, or array_like objects Values from these columns are extra data, to be used in widgets or Dash callbacks for example. This data is not user-visible but is included in events emitted by the figure (lasso selection etc.)

  • labels (dict with str keys and str values (default {})) – By default, column names are used in the figure for axis titles, legend entries and hovers. This parameter allows this to be overridden. The keys of this dict should correspond to column names, and the values should correspond to the desired label to be displayed.

  • title (str) – The figure title.

  • template (str or dict or plotly.graph_objects.layout.Template instance) – The figure template name (must be a key in plotly.io.templates) or definition.

  • width (int (default None)) – The figure width in pixels.

  • height (int (default None)) – The figure height in pixels.

  • branchvalues (str) – ‘total’ or ‘remainder’ Determines how the items in values are summed. Whenset to ‘total’, items in values are taken to be valueof all its descendants. When set to ‘remainder’, itemsin values corresponding to the root and the branches:sectors are taken to be the extra part not part of thesum of the values at their leaves.

  • maxdepth (int) – Positive integer Sets the number of rendered sectors from any given level. Set maxdepth to -1 to render all thelevels in the hierarchy.

三、返回值

plotly.graph_objects.Figure

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

岳涛@心馨电脑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值