Questions tagged [twinx]

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).

70 questions
1
vote
0 answers

Having trouble making good graphs with matplotlib, specifically with twinx()

I'm having trouble making my graphs look correct/decent using matplotlib. The lines don't switch colors, axes aren't showing up and in order to prevent the graphs from overlapping with labels and each other I have to make the graphs very…
Seto Shiba
  • 11
  • 2
1
vote
1 answer

Shared axis (twinx) hide y_axis values

I'm using the ax2 = ax1.twinx() attribute to have several graphs(3) with different scaling in the same plot, unfortunately, the values of the y-axis "run on top of each other" as shown here (right y axis, the blue values are sometimes hidden) Here…
DsCpp
  • 2,259
  • 3
  • 18
  • 46
1
vote
2 answers

Matplotlib secondary / dual axis - marking with circle and arrow - for black and white (bw) publishing

Usually two y-axes are kept apart with different colors, as shown in the example below. For publications it's often necessary to keep it distinguishable, even when it's printed in black and white. This is usually done by plotting circles around a…
Marcel
  • 285
  • 2
  • 10
1
vote
1 answer

Matplotlib: Boxplot and bar chart shifted when overlaid using twinx

When I create a barplot and overlay a bar chart using twin x then the boxes appear shifted by one to the right compared to the bars. This problem has been identified before (Python pandas plotting shift x-axis if twinx two y-axes), but the solution…
nostalghia
  • 15
  • 1
  • 6
1
vote
1 answer

matplotlib: controlling position of y axis label with multiple twinx subplots

I wrote a Python script based on matplotlib that generates curves based on a common timeline. The number of curves sharing the same x axis in my plot can vary from 1 to 6 depending on user options. Each of the data plotted use different y scales…
LMNCA
  • 21
  • 6
0
votes
0 answers

How to scale yleft and y right axis using twinx?

I need to scale the left or right y-axis in order to have just one data point in the chart for each set of data. This means that, I want the following solution: on the left y-axis 56 corresponds to 10.5 on the right y-axis, on the left y-axis…
chrisis
  • 119
  • 1
  • 1
  • 9
0
votes
0 answers

How to plot dual y-axes with no offset

I have a script that reads a database and retrieves timstamps and two values for each timestamp (level and altitude) here: dbc = r'Database Connection' QueryTable = "QueryTable" sql= "Identifier="+NWFID #Setup arrays x = [] …
0
votes
0 answers

Plotting a double y axis plot with both y related to each other (not trying to just align the two axis)

I'm trying to make a plot with double y axis so I use plt.subplots() let's say the two y axis has values like shown below x = [0,0,0,0,0,0,0,0,0,0,0,0] y1 = [1.3,1.2, 1.1, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2] y2 = [409.71, 243.016,…
Rajam E
  • 7
  • 4
0
votes
1 answer

imshow with twinx that is also aligned with tiles

There is a thread where the question was to add an automatically labelled twinx to Matplotlib's imshow. The result was: However, I would like the ticks on the second y-axis to be 1. manually settable and 2. aligned with the other ticks. Example…
Mew
  • 368
  • 1
  • 11
0
votes
1 answer

multiple xticks stacking when using twinx

I have a series that looks like this: 2022-10-08 0.357143 2022-10-09 0.500000 2022-10-10 0.500000 2022-10-11 0.500000 2022-10-12 0.642857 ... 2022-12-26 1.792857 2022-12-27 1.757143 2022-12-28 …
0
votes
0 answers

Bar plot and line plot shifts away from each other when using twinx()

I am dealing a CDF4 data using xarray to open it. I want to plot a line and a bar in just one figure, so I used twinx(). The problem is the xticks of the line and bar plot are not matched to each other. The xticks of the line plot is shifted one…
0
votes
0 answers

Error with twinx: 'PlotAccessor' object has no attribute 'twinx'

I'm using a for loop with a list of variables to create multiple plots against one variable each plot has an item in the list iterated in the for loop against the variable "PUMP FAILURE (1 or 0)" ATTEMPT ListOfVariables = ['Volumetric Flow Meter 1',…
0
votes
0 answers

in python, the tick labels of the secondary y-axis and third y-axis overlap when using parasite axis to plot multiple datasets

I used the parasite axis in python to plot three curves. The form of coordinates is like '5+1e7'. And the tick labels of the third y-axis and x-axis seem to be in the wrong place. As shown in the three pictures: the tick label '+1e7' of the x-axis…
Keloyi
  • 1
0
votes
1 answer

All X-Values Not Showing Up in Plot?

Hi first question in stack overflow. So any advice is welcomed. I am trying to set my plot to show all x labels (which is months) in my plot however plot automatically ignore the some of the x labels by showing [2018-07, 2019-01, 2019-07...]. FYI:…
0
votes
2 answers

matplotlib: Twinx() hides the minor grid of primary axis

I want to: A. See two y-axes (of two different graphs) with one x-axis. B. See major gridlines for x-axis c. See major and minor gridlines for y-axis of the primary plot I can plot the graph perfectly with only one y-axis, BUT as soon as I…
Pheytr1x
  • 31
  • 3