Skip to content

Improve axis mirror: 'allticks' - to show multiple ticks/labels for the same axis #2539

Closed

Description

@finger563

Context:
I have multiple plots that I want to interact with that each have different y axes, but I want them synchronized on their x axes. Right now the best way I know how to do this with plotly.js is to have them be subplots which shrare a single x-axis - but this means that each subplot does not have axis ticks or labels - which will only be shown on the "primary" xaxis.

Ideally I want them to link together for interaction (panning / zooming) but remain distinct.

How i want it to look (labels on all x-axes) but these are subplots which do not share x-axes and therefore do not interact together:
image

How it looks when they share the same x-axis (and therefore interactivity):
image

Is there something I'm missing that will let me synchronize the x-axes across multiple subplots? or a way to have each subplot xaxis have the labels?

Activity

  1. alexcjohnson commented on Apr 9, 2018

    @alexcjohnson
    Collaborator

    Right, there's no way to replicate the tick labels and title across multiple subplots. Once we implement #1549 that will be one way to do it, though that would be kind of heavy, both in terms of having to specify all the config multiple times and probably in terms of performance.

    Better would be for us to make some options within the one axis to replicate its tick labels and/or title. It can also be nice to show labels both top and bottom, if you have a single especially-large subplot.

    Supposedly we already have this for the tick marks using {ticks: 'inside', mirror: 'allticks'} but a) you're not using tick marks here so that wouldn't help you, and b) 'allticks' doesn't seem to work ATM - so I'll give this issue a bug label to remind us to fix that (though it's probably been broken for a while so it doesn't seem many people care about this...)

  2. Ricardosgeral commented on Jun 12, 2018

    @Ricardosgeral

    any news on this?

    I have three subplots in a column and need to replicate the tick labels and x title in all of then.
    How do i do it?
    thanks

  3. changed the title [-]Link axes together or show mutltiple labels for the same axis[/-] [+]Improve axis `mirror: 'allticks'` - to show multiple ticks/labels for the same axis[/+] on Mar 18, 2019
  4. karlicoss commented on Aug 20, 2019

    @karlicoss

    I think I've managed to achieve this by explicitly setting the showticklabels attribute:

        N = len(plots)
        figg = make_subplots(
            rows=N,
            cols=1,
            shared_xaxes=True,
            **kwargs,
        )
        for i in range(N):
            xaxis_name = 'xaxis' if i == 0 else f'xaxis{i + 1}'
            getattr(figg.layout, xaxis_name).showticklabels = True

    I get simultaneous zooming and tick labels displayed under each subplot

  5. removed
    bug
    on Aug 20, 2019
  6. HendrikRoehm commented on Dec 22, 2019

    @HendrikRoehm

    The solution suggested by karlicoss did not work for me in javascript. However, I found another hack: add a css text-shadow to the xaxis svg container via css. For example adding two copies of the xaxis labels:

    .xaxislayer-above {
         text-shadow: 0 -262px, 0 -490px;
    }
    

    This should not harm the performance, but the offset has to be computed manually.

  7. rpanai commented on Apr 17, 2020

    @rpanai

    @karlicoss

    for i in range(N):
            xaxis_name = 'xaxis' if i == 0 else f'xaxis{i + 1}'
            getattr(figg.layout, xaxis_name).showticklabels = True

    you could avoid getattr using

    for i in range(N):
            xaxis_name = 'xaxis' if i == 0 else f'xaxis{i + 1}'
            figg.layout[yaxis_name].showticklabels = True
  8. pablomadoery commented on Jul 26, 2021

    @pablomadoery

    fig.update_xaxes(showticklabels=True) will show xticks for all subplots.
    put it after making all subplots.

  9. gvwilson commented on Jun 11, 2024

    @gvwilson
    Contributor

    Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions