Skip to content
Advertisement

Python: Create annotation space above the graph in Plotly

I would like to create additional space for annotations within the plot (see green area in attached image). At the moment, the y-axis defines my height of the plot. Can I push the plot beyond the y.max limit/hide the y-axis after a certain point (marked red in the image)? I try to avoide the axis reaching into the ‘comment section’ (green).

Thank you!

enter image description here

enter image description here

Advertisement

Answer

I stumbled on this question after answering another of your questions and thought it was interesting.

Is this what you’re after?

Key Elements:

The key elements of creating the elevated annotation are:

  • xref and yref are set to 'paper', thus using the graph’s background for xy coordinates rather than graph data values
  • Using > 1.00 for the y positioning
  • layout['margin'] top set to a value to create a top margin, thus pushing the graph area down

Sample Code:

It’s really much simpler than it looks.

JavaScript

Note:

You’ll have to create your own graph title (rather than relying on the title parameter available in layout) as you’ll need to position the graph title yourself. Otherwise the automatic title and annotations will overlap.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement