Skip to main content

All Questions

Tagged with
0 votes
2 answers
305 views

How to add legend when using twinx

I am trying to plot 2 values with same x axis values (time) but different y axis values. I am trying to add legend to the plot, however, I keep getting 2 legends for the same variable instead of one ...
Nouredin Modl's user avatar
2 votes
3 answers
1k views

Add a legend that covers the lines of the twinx axis

I have this python code. it twinx the axis ax and plots some function on both axis I plot the legend on ax1 The problem is that the legend is not covering the curves of ax2 It is possible to ...
Giggi's user avatar
  • 689
0 votes
1 answer
315 views

How to insert a legend in a subplot secondary y axis and twinx [duplicate]

Hi all my code below works with the exception of the legend. I tried to brute force something to come up but the actual lines in each legend don't match. After correcting for the get_labels_handles ...
pythonpypy's user avatar
1 vote
1 answer
2k views

Combining labels for a legend from two separate axes objects error

I have a graph which needs two y-axis. Having created the second y-axis I now want to add the labels from each of the two axes instances into one legend, I have seen a method on SO here Secondary axis ...
Windy71's user avatar
  • 889
2 votes
1 answer
293 views

How to line plot multiple columns with nan and on twinx / secondary_y

The graph is fixed now but I am having troubles plotting the legend. It only shows legend for 1 of the plots. As seen in the picture below I am trying to plot a double axis graph with twinx but I am ...
HOA's user avatar
  • 131
1 vote
2 answers
3k views

Secondary axis multiple legends

I have a plot that has a secondary axis. Axis 1 has two data sets plotted against it. Axis 2 has one data set. I can get two legends (one from Axis 1 and one from Axis 2) like how I want them - one ...
rmore911's user avatar
  • 205
0 votes
1 answer
496 views

ax.twinx label appears twice

I have been trying to make a chart based on an excel, using Matplotlib and Seaborn. Code is from the internet, adapted to what I want. The issue is that the legend appears 2 times. Do you have any ...
Andrei Ungurean's user avatar
1 vote
1 answer
934 views

interactive legend with twinx - matplotlib

i want to create a plot with two y-axis and interactive legend. I made a minimal "working" example based on: https://matplotlib.org/3.1.1/gallery/event_handling/legend_picking.html import matplotlib....
Cyruu Kairoo's user avatar
14 votes
3 answers
8k views

Data being plotted over legend when using twinx

I'm trying to use Python and Matplotlib to plot a number of different data sets. I'm using twinx to have one data set plotted on the primary axis and another on the secondary axis. I would like to ...
0235ev's user avatar
  • 207
481 votes
11 answers
480k views

Secondary axis with twinx(): how to add to legend

I have a plot with two y-axes, using twinx(). I also give labels to the lines, and want to show them with legend(), but I only succeed to get the labels of one axis in the legend: import numpy as np ...
joris's user avatar
  • 138k