For questions about the matplotlib twinx method, which creates a new Axes with an invisible x-axis and an independent y-axis positioned opposite to the original one (i.e. at right).
Questions tagged [twinx]
70 questions
0
votes
1 answer
Plot pandas line chart using dual axis and loop through dataframe
I have dataframe like this,
data = {'TIMEFRAME':['9/12/2014 17:52', '10/12/2014 5:02', '10/12/2014 8:04'],
'Volumetric Flow Meter 1':[0.82, 0.88, 0.9],
'Pump Speed (RPM)':[2.5,2.7,3.01],
'Data Source':['raw data','raw…

Tahsin Alam
- 147
- 1
- 10
0
votes
1 answer
How to share 2D axis on a 3D plot in matplotlib
I am able to plot a 3D surface plot with a 2D contour plot just fine
but I would also like to share the x axis of the 2D plot using ax.twinx() like I've done in a separate plot here:
However, when I add this to the ax including the 3D contour plot…

user3006887
- 71
- 1
- 8
0
votes
0 answers
ticks for matplotlib twinx axes not current
Hey I have issue with the matplotlib twinx axes, I have 2 plot with the same X ticks,
But when I set them both in the same plot with twinx I get wrong plot.
The first plot data:
Potential_Date_month
1 0.033616
2 0.033256
3 0.026578
4 …

Yair hadad
- 437
- 3
- 17
0
votes
0 answers
How to have two labels on the y-axis and one label on the x-axis?
I am trying to make a Python plot with labels on both the right and left sides on the vertical axis. However, I cannot manage to get a label on the bottom of the horizontal axis. Can anyone help me, please?
I have made this code, and it works fine,…

Kevin
- 1
- 1
0
votes
1 answer
How do you plot two different y-axes using a loop with twinx?
I have a pandas data frame, region, containing the prices of flats (Flat) and detached properties (Detached) in areas of the UK over time (the column Month). I'm trying to obtain plots of the change in price over time of both flats and detached…

Brudalaxe
- 191
- 1
- 8
0
votes
1 answer
twinx messes up colorbar of pcolormesh plot
I have encountered a problem when trying to plot some values on top of an image. The problem is that I cannot really place the colorbar properly. With properly I mean an image where I overlay a line plot. This line plot should have its yaxis on the…

felipon
- 5
- 4
0
votes
1 answer
How to add secondary matplotlib axis with non-uniform interval and different scale
I have three arrays: time, steps and volume. I want to plot how the volume (Y-axis) changes over time (X-axis) and demonstrate how the time correlates with steps (2nd X-axis).
time = np.array([1.280000e-07, 1.322240e-07, 1.364480e-07, 1.288448e-06,
…

user40
- 1,361
- 5
- 19
- 34
0
votes
1 answer
Wrap text based on axis limits instead of chart limits, twinx matplotlib
I have been trying to wrap the text in a chart made with matplotlib. My problem right now is I made the chart using twinx but the text I want to wrap is wrapping in regards to the whole chart instead of the axis I want it to only be on. I don't…

Ashley Adams
- 95
- 1
- 12
0
votes
0 answers
'numpy.ndarray' object has no attribute 'twinx'
I am trying to plot histograms with two y axes.
fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(12, 8))
ax2 = ax.twinx()
but this line (ax2 = ax.twinx()) results in error:
'numpy.ndarray' object has no attribute 'twinx'
0
votes
1 answer
Matplotlib widget, secondary y axis, twinx
i use jupyterlab together with matplotlib widgets. I have ipywidgets installed.
My goal is to choose which y-axis data is displayed in the bottom of the figure.
When i use the interactive tool to see the coordinates i get only the data of the right…

Jakob
- 168
- 1
- 6
0
votes
2 answers
X Axis date range changing when using twinx()
When I plot a graph, the bargraph's date changes to 1970's while the overlaid lineplot remains correct. If I remove the code from twinx() onward, the bargraph displays correctly with the correct date range. I have also tried removing the x…

SensingFailure
- 17
- 3
0
votes
1 answer
Is it possible to have a given number (n>2) of y-axes in matplotlib?
prices = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
columns=['a', 'b', 'c'])
I have my prices dataframe, and it currently has 3 columns. But at other times, it could have more or fewer columns. Is there a way to…

Tony
- 221
- 1
- 4
- 11
0
votes
1 answer
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 with twinx(): how to add to legend? but it…

Windy71
- 851
- 1
- 9
- 30
0
votes
0 answers
TypeError-Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'
I have plotted two plots on the same axis using twinx() but the output isn't correct. The plots are not aligned with respect to zero axis. I am sharing the plot below.
Days percentage change is float and total traded quantityis integer.
fig =…

mtr_007
- 59
- 1
- 10
0
votes
1 answer
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 recommendations?
Report screenshot: enter image…

Andrei Ungurean
- 15
- 3