0

I need to suppress the Y axis values on right hand side which comes when you use two different Y axis labels with common X axis I want to remove the Y axis values which come on the right side of the axis :

eg:

import numpy as np

import matplotlib.pyplot as plt


list1=[1,2,3,4,5,6,7]

list2=[2,4,6,8,10,12,14]

list3=[2,4,6,8,10,12,14]

fig, ax1 = plt.subplots(2)

ax2 = ax1[0].twinx() # ax2 and ax1 will have common x axis and different y axis
ax1[0].plot(list1, list2, label="sin", color='r')
ax2.plot(list1, list3, label="sinh", color='b')

When I add yaxt="n" to ax2.plot line above it gives me an error:AttributeError: 'Line2D' object has no property 'yaxt'

Any pointers would be helpful

enter image description here

Redox
  • 9,321
  • 5
  • 9
  • 26
Kapil
  • 149
  • 1
  • 5
  • The code above does not give the plot shown in the picture. Please check.... – Redox Jun 05 '23 at 13:17
  • 1
    Does this answer your question? [matplotlib shared axis (twinx) hide y\_axis values](https://stackoverflow.com/questions/58315830/matplotlib-shared-axis-twinx-hide-y-axis-values) – Redox Jun 05 '23 at 13:24
  • Yeah the above one helps answer my question .. Thanks!! – Kapil Jun 05 '23 at 14:32

0 Answers0