question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`plotly.express.scatter_geo`: misleading argument type for the `size` argument

See original GitHub issue

The documentation of the function plotly.express.scatter_geo [1] states that the size argument can be set to an integer.
When you do that, you’ll get an error similar to the following:

Traceback (most recent call last):
  File "/path/to/map.py", line 11, in <module>
    fig_map = px.scatter_geo(
  File "/path/to/miniconda3/lib/python3.8/site-packages/plotly/express/_chart_types.py", line 1031, in scatter_geo
    return make_figure(
  File "/path/to/miniconda3/lib/python3.8/site-packages/plotly/express/_core.py", line 1861, in make_figure
    args = build_dataframe(args, constructor)
  File "/path/to/miniconda3/lib/python3.8/site-packages/plotly/express/_core.py", line 1377, in build_dataframe
    df_output, wide_id_vars = process_args_into_dataframe(
  File "/path/to/miniconda3/lib/python3.8/site-packages/plotly/express/_core.py", line 1183, in process_args_into_dataframe
    raise ValueError(err_msg)
ValueError: Value of 'size' is not the name of a column in 'data_frame'. Expected one of ['col_name_1', 'col_name_2', 'col_name_3'] but received: 20

After some research, [2] [3] I found out that the correct way of doing this is via the method fig.update_traces(marker=dict(size=20))
So, we need to update the documentation to avoid obsolete and misleading argument types

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nicolaskruchtencommented, May 13, 2021

Yeah, I should really document both the “integers are interpreted as col names” and “px.Constant is a valid input” in the docstrings. Thanks for the nudge 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

plotly.express.scatter_geo — 5.11.0 documentation
Parameters. data_frame (DataFrame or array-like or dict) – This argument needs to be passed for column names (and not keyword names) to be...
Read more >
Plotly-Express: How to fix the color mapping when setting ...
I found a solution. The function px.scatter has an argument color_discrete_map which is exactly what I needed. color_discrete_map takes a ...
Read more >
plotly.graph_objects.Scattergeo — 5.11.0 documentation
size. sizesrc. Sets the source reference on Chart Studio Cloud for size . Returns. Return type. plotly.graph_objects.scattergeo.hoverlabel.Font.
Read more >
[BUG] error with size kw in px functions and non-str argument
import numpy as np import plotly.express as px df ... I thought ( df.pop is not a valid argument) but the error message...
Read more >
Visualization with Plotly.Express: Comprehensive guide
Plotly.Express offers shorthand syntax to create many chart types. ... The length of argument `wide_cross` is 25, whereas the length of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found