vishnu m c
vishnu m c

Reputation: 887

showing x axis label for each graph in plotly subplot with shared x axis

I have created a subplot with plotly.JS , x axis is shared for each graph as given in the below picture. shared x axis

I want to show the x axis values for all graphs in the subplot instead for showing it only for graph at bottom. I achieved this using anchor attribute, but the graphs are not aligned well. Look at the below picture, here 600 of graph2 is not positioned exactly to the other two graphs. without sharing xaxis

I want all the graph to share x axis as well as show the x axis values on each graph.

Upvotes: 4

Views: 1063

Answers (1)

confusedCoder
confusedCoder

Reputation: 223

This is an old question but I spent a lot of time figuring it out, so hopefully it will still be useful. It turns out to be very doable just not using the grid layout. Here's a pen that demonstrates it:

https://codepen.io/cerenoc/pen/wvVaYQj

The key parts here are:

  1. using domain to shrink the plots a bit along y to leave room for x axis labels
  2. using matches to specify shared axes
  3. using 'anchor' to position the new x-axis

Upvotes: 0

Related Questions