Skip to content

Create a "stick-inside" mode for ticks labels #1278

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

Closed
EBoisseauSierra opened this issue Nov 20, 2018 · 4 comments
Closed

Create a "stick-inside" mode for ticks labels #1278

EBoisseauSierra opened this issue Nov 20, 2018 · 4 comments

Comments

@EBoisseauSierra
Copy link

EBoisseauSierra commented Nov 20, 2018

Context

Say we have a first quadrant chart:

ticks1

One can notice that ticks' label are horizontally/vertically centred (compared to the ticks themselves) on the horizontal/vertical axis, respectively.

This makes that first and last ticks value "stick out" from the graph; what can be a bit ungainly — especially if one shows one axis only:

ticks3

This is also inconvenient when you want to precisely align you axes with elements surrounding your picture (e.g., in the example above, if you want the 0% tick mark to be the most-left point of the picture).

Question

➥ Could it be possible to have a "stick inside" mode for ticks values?

The idea is to change the vertical/horizontal alignment of the first and last ticks values:

  • left and right aligned, respectively, for the horizontal axis:
    ticks3

  • bottom and top aligned, respectively, for the vertical axis:
    ticks4

Our first example would then look like this:
ticks5

Variant

An even more super-duper mode would enable us to choose which end on the axis to "stick inside", so that one could make such graph:
ticks6

@jonmmease
Copy link
Contributor

Hi @EBoisseauSierra,

Thanks for the detailed description of your request. This is something that would need to be implemented in plotly.js, and then plotly.py would get it automatically. Would you mind moving this issue to https://github.com/plotly/plotly.js/issues? Thanks!

@EBoisseauSierra
Copy link
Author

@jonmmease done, see issue #3292!

It might not be the right place to ask, but could you please {explain me/redirect me to where I could understand} why changes in plotly.js are automatically got by plotly.py?

@etpinard
Copy link
Contributor

now in plotly/plotly.js#3292

@jonmmease
Copy link
Contributor

Thanks @EBoisseauSierra!

It might not be the right place to ask, but could you please {explain me/redirect me to where I could understand} why changes in plotly.js are automatically got by plotly.py?

Sure! plotly.js is the JavaScript library that actually performs all of the rendering (drawing axes, markers, etc.). In plotly.js world, all visualization are specified using JSON (e.g. https://github.com/plotly/plotly.js/blob/master/test/image/mocks/scatter-colorscale-colorbar.json). The primary job of plotly.py is to provide a nice Python API for creating these JSON data structures.

plotly.js maintains a detailed schema describing all of the valid properties for each trace type and the layout (See https://github.com/plotly/plotly.js/blob/master/dist/plot-schema.json). The schema includes not only the property names, but also data types, valid ranges of values, and descriptions.

In plotly.py, each time we update the version of plotly.js the entire plotly.graph_objs hierarchy of Python classes is automatically generated from the updated plotly.js schema (See https://github.com/plotly/plotly.py/tree/master/codegen). So when plotly.js introduces new properties (say a new layout.xaxis.stickinside property), as long as the property has an existing datatype (probably just a boolean in this case) then this property will automatically be added by plotly.py to the plotly.graph_objs.layout.XAxis class during this code generation process. And the new property will automatically have a docstring and detailed property validation (i.e. validating that the property is set to a boolean value).

This code generation step is something we added in version 3.0, and it has really helped us keep plotly.py up to date with plotly.js much more quickly and reliably.

Hope that helps!

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

No branches or pull requests

3 participants