Open afeld opened 9 months ago
Thanks @afeld - I love those class notes, beautiful!
It would certainly be useful to have a warning in this case, but it's a little tricky to figure out how to make that happen. The Python-side validators are all codegen from the JavaScript schema, and anyway they aren't intended to capture interactions between different attributes. The obvious place to put this is in JavaScript where we put this all together, and some error situations already do generate messages there, though it's not clear to me if the cases you're describing would: https://github.com/plotly/plotly.js/blob/master/src/lib/geo_location_utils.js - that said even if we do get the right messages there you'll only see them in the JS console, not in Python or in the main browser window, and most Python users won't know to look there.
Thanks, and thanks for the quick response!
After a bunch of experimentation, reading source code, and some help from ChatGPT, I've learned that the file you pointed me to does have that functionality already, but it's disabled by default. It can be enabled with:
Plotly.setPlotConfig({ logging: 2 });
…but that isn't documented 🙃 Created an example in Codepen.
Unfortunately, it's not clear to me how to do that from Python/Colab. Configuration options can be passed to .show()
… but logging
and notifyOnLogging
"should ONLY be set via Plotly.setPlotConfig". Created a corresponding example in Colab.
Thoughts?
even if we do get the right messages there you'll only see them in the JS console, not in Python or in the main browser window, and most Python users won't know to look there.
notifyOnLogging: 2
sidesteps that problem by temporarily displaying them on the map. I'd argue that should be the default setting to avoid confusion, despite the risk of causing visual noise.
Issue around allowing logging to be configured via newPlot()
in JavaScript (and thus show()
in Python): https://github.com/plotly/plotly.js/issues/4555
I teach a class for students that are new to coding. We use plotly, and I'm happy to have a package that gets students good-looking graphs in so little code.
I introduce plotly's choropleth maps, and have repeatedly run into the issue where the students get confused by what the
featureidkey
is referring to and how that relates to thelocations
. I do my best to explain this, but they are (understandably) confused working across CSVs and GeoJSON. One student just hit an issue where they were trying to use FIPS codes, but theirlocations
column had leading whitespace. When the rows are unable to be matched to a feature, it fails silently.My feature request is to provide a warning when the
featureidkey
andlocations
have zero matches.I haven't contributed to the plotly codebase before, but I'd be open to doing so if the maintainers are open to receiving this. Presumably the place to add this check is one of the validators?
Thanks!