【Python百日进阶-数据分析】Day126 - plotly折线图:px.line()语法

一、scatter_geo语法

plotly.express.line(data_frame=None,
                    x=None,
                    y=None,
                    line_group=None,
                    color=None,
                    line_dash=None,
                    symbol=None,
                    hover_name=None,
                    hover_data=None,
                    custom_data=None,
                    text=None,
                    facet_row=None,
                    facet_col=None,
                    facet_col_wrap=0,
                    facet_row_spacing=None,
                    facet_col_spacing=None,
                    error_x=None,
                    error_x_minus=None,
                    error_y=None,
                    error_y_minus=None,
                    animation_frame=None,
                    animation_group=None,
                    category_orders=None,
                    labels=None,
                    orientation=None,
                    color_discrete_sequence=None,
                    color_discrete_map=None,
                    line_dash_sequence=None,
                    line_dash_map=None,
                    symbol_sequence=None,
                    symbol_map=None,
                    markers=False,
                    log_x=False,
                    log_y=False,
                    range_x=None,
                    range_y=None,
                    line_shape=None,
                    render_mode='auto',
                    title=None,
                    template=None,
                    width=None,
                    height=None)

在 2D 线图中,每行data_frame表示为 2D 空间中折线标记的顶点。

二、参数

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

  • x ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于在笛卡尔坐标中沿 x 轴定位标记。或者可以是列引用列表或 array_likes 列表,在这种情况下,数据将被视为“宽”而不是“长” x。 y

  • y(str或int或Series或array-like)– 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于在笛卡尔坐标中沿 y 轴定位标记。或者可以是列引用列表或 array_likes 列表,在这种情况下,数据将被视为“宽”而不是“长” x。 y

  • line_group ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于将行分组data_frame为行。

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

  • line_dash(str或int或Series或array-like)– 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于将破折号模式分配给线条。

  • symbol (str或int或Series或array-like)- 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于将符号分配给标记。

  • 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 回调。此数据对用户不可见,但包含在图形发出的事件中(套索选择等)

  • text ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值在图中显示为文本标签。

  • facet_row ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于在垂直方向上为多面子图分配标记。

  • facet_col ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于在水平方向上为多面子图分配标记。

  • facet_col_wrap ( int ) – 最大分面列数。以该宽度包装列变量,以便列分面跨越多行。如果为 0,则忽略,如果设置facet_row了或 a ,marginal则强制为 0。

  • facet_row_spacing ( float between 0 and 1 ) – 分面行之间的间距,以纸张为单位。使用 facet_col_wrap 时,默认值为 0.03 或 0.0.7。

  • facet_col_spacing ( float between 0 and 1 ) – 分面列之间的间距,以纸张为单位默认为 0.02。

  • error_x ( str or int or Series or array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于确定 x 轴误差线的大小。如果error_x_minus是None,误差线将是对称的,否则error_x仅用于正方向。

  • error_x_minus ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于在负方向调整 x 轴误差线的大小。error_x 如果是则忽略None。

  • error_y ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于确定 y 轴误差线的大小。如果error_y_minus是None,误差线将是对称的,否则error_y仅用于正方向。

  • error_y_minus ( str or int or Series or array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于在负方向调整 y 轴误差线的大小。error_y 如果是则忽略None。

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

  • animation_group ( str或int或Series或array-like ) – 中的列名data_frame,或者 pandas Series 或 array_like 对象。此列或 array_like 中的值用于提供跨动画帧的对象恒定性:具有匹配 animation_group 的行将被视为描述每个帧中的相同对象。

  • category_orders(带有 str 键和 str 值列表的字典(默认{}))——默认情况下,在 Python 3.6+ 中,轴、图例和构面中的分类值的顺序取决于这些值第一次遇到的顺序data_frame(并且没有在低于 3.6 的 Python 中默认保证顺序)。此参数用于强制对每列的值进行特定排序。此 dict 的键应对应于列名,值应是与所需的特定显示顺序相对应的字符串列表。

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

  • orientation (str,‘h’水平或’v’垂直之一。) - (默认’v’如果提供 和x并且y都连续或都分类,否则’v’('h' )是分类和 )是连续的,否则提供'h' )) if x(yy(x’v’() if only x(y

  • 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 (dict with str keys and str values (default {})) – 字符串值应该定义有效的 CSS-colors 用于覆盖 color_discrete_sequence以将特定颜色分配给与特定值对应的标记。中的键color_discrete_map应该是由 表示的列中的值color。或者,如果 的值color是有效颜色,则’identity’可以传递字符串以直接使用它们。

  • line_dash_sequence ( list of str ) – 字符串应该定义有效的 plotly.js dash-patterns。设置时line_dash ,该列中的值通过line_dash_sequence按 中描述的顺序 循环分配给破折号模式category_orders,除非 的值line_dash是 中的键 line_dash_map。

  • line_dash_map(带有 str 键和 str 值的字典(默认{}))- 字符串值定义 plotly.js dash-patterns。用于覆盖 line_dash_sequences以将特定的破折号模式分配给与特定值对应的行。中的键line_dash_map应该是由 表示的列中的值line_dash。或者,如果 的值line_dash是有效的短划线名称,则 'identity’可以传递字符串以使它们直接使用。

  • symbol_sequence ( list of str ) – 字符串应该定义有效的 plotly.js 符号。设置时symbol,该列中的值通过 symbol_sequence按 中描述的顺序循环分配符号category_orders,除非 的值symbol是 中的键symbol_map。

  • symbol_map (dict with str keys and str values (default {})) - 字符串值应该定义 plotly.js 符号 用于覆盖 symbol_sequence以将特定符号分配给与特定值对应的标记。中的键symbol_map应该是由 表示的列中的值symbol。或者,如果 的值symbol 是有效的符号名称,则’identity’可以传递字符串以使它们直接使用。

  • markers (boolean (default False)) - 如果True是,标记显示在行上。

  • log_x (boolean (default False)) – 如果True是,x 轴在笛卡尔坐标中按对数缩放。

  • log_y (boolean (default False)) – 如果True是,y 轴在笛卡尔坐标中按对数缩放。

  • range_x (两个数字的列表) – 如果提供,则覆盖笛卡尔坐标中 x 轴上的自动缩放。

  • range_y (两个数字的列表) – 如果提供,则覆盖笛卡尔坐标中 y 轴上的自动缩放。

  • line_shape (str (default ‘linear’)) --‘linear’或之一’spline’。

  • render_mode ( str ) –或’auto’,默认值之一控制用于绘制标记的浏览器 API。’ 适用于少于 1000 个数据点的图形,并允许完全矢量化输出。 对于 1000 点以上的可接受性能可能是必需的,但会光栅化部分输出。 使用启发式方法来选择模式。‘svg’‘webgl’‘auto’‘svg’webgl’‘auto’

  • title ( str ) – 图形标题。

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

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

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

三、返回类型

plotly.graph_objects.Figure

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

岳涛@心馨电脑

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

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

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

打赏作者

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

抵扣说明:

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

余额充值