Skip to content

Make colorbars respect template configurations #1867

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

Merged
merged 2 commits into from
Nov 6, 2019

Conversation

joelostblom
Copy link
Contributor

Currently, none of the colorbar options in the templates are effective and colorbars are rendered the same regardless of the template. This PR adds the template colorbar options under the layout.coloraxis key instead of assigning them to individual figures. As a bonus the json template files are now about half the size.

I removed the colorbar helper function because I didn't see any other use for it. I also removed the figure level colorscale assignments because it seems like the figures pick up these from the template just fine.

You can see the effect of the proposed changes below.

========== Current =================== This PR =======

image

@joelostblom joelostblom mentioned this pull request Nov 4, 2019
6 tasks
@nicolaskruchten
Copy link
Contributor

Thanks for the PR!

Currently, none of the colorbar options in the templates are effective and colorbars are rendered the same regardless of the template

Is this true of all colorbars or just the coloraxis colorbars? I.e. if you have a colorbar that's defined in a trace, do the current settings work?

@joelostblom
Copy link
Contributor Author

joelostblom commented Nov 4, 2019

if you have a colorbar that's defined in a trace, do the current settings work?

Hmm, not sure. Could you provide a code test case to run? I saw that go.Colorbar is deprecated so not sure what function to use to create a colorbar as a trace rather than in the coloraxis.

@nicolaskruchten
Copy link
Contributor

All the non-PX code here uses "trace-defined" colorbars rather than coloraxis https://plot.ly/python/colorscales/

@joelostblom
Copy link
Contributor Author

joelostblom commented Nov 4, 2019

Thanks!

I tried the "Colorscale for Scatter Plots" example with colorbar=dict(title="Colorbar"). it seems to be are unaffected by the changes I made and ignore templates both before and after this PR:

Before:
image

After:
image

@nicolaskruchten
Copy link
Contributor

OK so the problem with the example above is that the current builtin templates don't set a colorscale default for scatter, only the listed trace types. I don't agree with removing anything from the current templates (this would be a breaking change), although I don't mind adding something to cover coloraxis.colorbar

@nicolaskruchten
Copy link
Contributor

For example, the current settings do work for heatmaps which are not generated with PX:

image

@joelostblom
Copy link
Contributor Author

Ah ok I see. I didn't realize that the colorscale would not work with go.Heatmap when it was working with go.Scatter and px.density_heatmap. Sorry, didn't mean to remove any functionality.

I reverted all removals, rebased, and force pushed. The current version lets the template modify the colorbars and colorscales of both go.Heatmap and px.density_heatmap.

@nicolaskruchten
Copy link
Contributor

Can you add the colorbar settings to the other traces types too please? even if only the scatter* family? :)

@joelostblom
Copy link
Contributor Author

Sorry, I don't understand, can you elaborate on the changes required?

The PR already works with the px.scatter colorbar.

image

The colorscale is already picked up by go.Scatter so don't think I need to add that separately as for the heatmaps.

image

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Nov 5, 2019 via email

@nicolaskruchten nicolaskruchten merged commit 2c3fd9b into plotly:master Nov 6, 2019
@joelostblom joelostblom deleted the template-colorbars branch November 6, 2019 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants