Home > Mobile >  how to change the scale of the x-axis so that the orange and blue graphs are displayed correctly
how to change the scale of the x-axis so that the orange and blue graphs are displayed correctly

Time:11-23

I cannot correctly depict two graphs: orange and blue. I've read the documentation, tried changing the values until nothing comes out. How to show these graphs, as in 1 picture, together with others correctly

enter image description here

I get it like this

enter image description here

My code My code:

import matplotlib.pyplot as plt
import numpy as np



x = np.array([0.264, 0.331, 0.397, 0.417, 0.438, 0.45, 0.459, 0.466])
y = np.array([0.01, 0.1, 1, 2, 4, 6, 8, 10])
# creating scatter plot with both negative
# and positive axes
plt.plot(x, y, marker='o')
x = np.array([0.375, 0.435, 0.494, 0.512, 0.53, 0.541, 0.548, 0.564])
y = np.array([0.01, 0.1, 1, 2, 4, 6, 8, 10])
plt.plot(x, y, marker='o')
x2points=np.array([-3.672, -3.733, -3.793, -3.811, -3.828, -3.839, -3.846, -3.852])
y2points = np.array([-0.01, -0.1, -1, -2, -4, -6, -8, -10])
plt.plot(x2points, y2points, marker = 'o')
x2points = np.array([-14.86, -14.931, -14.998, -15.018, -15.039, -15.051, -15.06, -15.067])
y2points = np.array([-0.01, -0.1, -1, -2, -4, -6, -8, -10])
plt.plot(x2points, y2points, marker='o')
# adding vertical line in data co-ordinates
plt.axvline(0, c='black', ls='--')

# adding horizontal line in data co-ordinates
plt.axhline(0, c='black', ls='--')
plt.xticks([-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1])
plt.yticks([-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

# visualizing the plot using plt.show() function
plt.show()

The result I want to get two plots close together, sharing the y-axis

  • Related