Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scattermap and map to plotly.py templates similar to scattermapbox and mapbox #4879

Closed
archmoj opened this issue Nov 14, 2024 · 9 comments · Fixed by #4881
Closed

Add scattermap and map to plotly.py templates similar to scattermapbox and mapbox #4879

archmoj opened this issue Nov 14, 2024 · 9 comments · Fixed by #4881
Assignees
Labels
bug something broken P1 needed for current cycle

Comments

@archmoj
Copy link
Contributor

archmoj commented Nov 14, 2024

In order for scattermap and map behave similar to scattermapbox and mapbox, we should add scattermap and map to the templates inside packages/python/plotly/plotly/package_data/templates/.

@archmoj archmoj added the P1 needed for current cycle label Nov 14, 2024
@archmoj
Copy link
Contributor Author

archmoj commented Nov 14, 2024

cc: @gvwilson @ndrezn

@LiamConnors LiamConnors removed their assignment Nov 14, 2024
@archmoj
Copy link
Contributor Author

archmoj commented Nov 14, 2024

Are there similar defaults in ddk that should be updated?

@gvwilson
Copy link
Contributor

gvwilson commented Nov 14, 2024

Are the .json files in packages/python/plotly/plotly/package_data/templates/ generated by a script? If so, what script and where does the data come from? (the compact formatting of these .json files leads me to believe they aren't hand-edited.)

  1. packages/python/plotly/setup.py refers to package_data/templates/*.
  2. packages/python/plotly/templategen/* seems to be the generator.

@gvwilson gvwilson added the feature something new label Nov 14, 2024
@archmoj
Copy link
Contributor Author

archmoj commented Nov 14, 2024

@LiamConnors Are these templates auto generated?

@archmoj
Copy link
Contributor Author

archmoj commented Nov 14, 2024

We should add map alternatives e.g. here and in other places similar to mapbox.

@gvwilson
Copy link
Contributor

gvwilson commented Nov 14, 2024

It appears that templategen is invoked manually rather than automatically.

@gvwilson
Copy link
Contributor

gvwilson commented Nov 14, 2024

Progress of a sort. Please note that I'm working off the master branch, which may not have the most up-to-date files.

  1. Modified packages/python/plotly/templategen/utils/__init__.py to change template.data.heatmapgl[0] to template.data.heatmap[0]. (Step 3 fails without this change.)
  2. Moved the interesting bits of packages/python/plotly/templategen/__init__.py to packages/python/plotly/templategen/__main__.py so that we can run python -m templategen from the packages/python/plotly/templategen directory.
  3. Ran that command, which generated new versions of these six files:
    • plotly/package_data/templates/ggplot2.json
    • plotly/package_data/templates/plotly.json
    • plotly/package_data/templates/plotly_dark.json
    • plotly/package_data/templates/plotly_white.json
    • plotly/package_data/templates/seaborn.json
    • plotly/package_data/templates/simple_white.json
  4. Note that this command did not generate new versions of gridon.json, presentation.json, xgridoff.json, or ygridoff.json - I don't know why.

I'm attaching pretty-printed versions of the old and new versions of plotly.json. The only difference is that the new version has an entry for scattermap as well as scattermapbox, while the old version only had scattermapbox.
Note that I have not added map since there wasn't an entry for mapbox, and that I didn't have to add scattermap (it was already there).

new-plotly-indented.json

old-plotly-indented.json

@archmoj
Copy link
Contributor Author

archmoj commented Nov 14, 2024

Thanks @gvwilson That's a good progress to help continue automation of this process.
Are you going to open a pull request?
If so on master please git pull switch to have the latest files.
Then please switch to a new branch other than master and and rerun the script and commit the changes.
You may consider skipping the pretty-print step in your PR specially if that helps the diffs to be clearer.

gvwilson added a commit that referenced this issue Nov 14, 2024
See #4879 for discussion.

1.  Move material from `packages/python/plotly/templategen/__init__.py` to new file `packages/python/plotly/templategen/__main__.py` so that we can run `python -m templategen` from the `packages/python/plotly` directory.
2.  Modify `packages/python/plotly/templategen/utils/__init__.py` to change `heatmapgl` reference to `heatmap`.
3.  Run `python -m templategen` to generate new versions of the following files:
    -   `packages/python/plotly/plotly/package_data/templates/ggplot2.json`
    -   `packages/python/plotly/plotly/package_data/templates/plotly.json`
    -   `packages/python/plotly/plotly/package_data/templates/plotly_dark.json`
    -   `packages/python/plotly/plotly/package_data/templates/plotly_white.json`
    -   `packages/python/plotly/plotly/package_data/templates/seaborn.json`
    -   `packages/python/plotly/plotly/package_data/templates/simple_white.json`
@gvwilson
Copy link
Contributor

I've created a new branch off master with my changes called add-new-traces-to-templategen - @archmoj please take it from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P1 needed for current cycle
Projects
None yet
3 participants