简体   繁体   English

为什么 y 轴的增量为 1 而不是 90

[英]Why is the y axis in increments of 1 rather than 90

I want to make a sine graph but the y-axis is off, how can i change that.我想制作一个正弦图,但 y 轴关闭,我该如何改变它。

Also that do the 3 numbers in the brackets after linspace mean?另外,linspace 后面括号中的 3 个数字是什么意思?

    import matplotlib.pyplot as plt
import numpy as np


x = np.linspace(0, 7, 100)
y = np.sin(x)


plt.plot(x, y)
plt.grid(True)
plt.show()

Thank You谢谢你

See set_xlim to adjust the limits of the x-axis.请参阅set_xlim以调整 x 轴的限制。

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 7, 100)
y = np.sin(x)

fig, ax = plt.subplots()
ax.plot(x,y)
ax.grid(True)
ax.set_xlim(0,7)
plt.show()

Before:前:

在此处输入图片说明

After:后:

在此处输入图片说明

The three numbers in the np.linspace command mean start , stop , and num . np.linspace 命令中的三个数字表示startstopnum Ie it generates an array of 100 evenly spaced numbers between 0 and 7.即它生成一个由 0 到 7 之间的 100 个均匀间隔的数字组成的数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 倾斜轴2D图,其中xy轴成60度而不是90度 - tilted axis 2D plot where x y axis make 60 degree rather than 90 Python plotly 折线图 y 轴打印顺序是从 CSV 读取而不是顺序 - Python plotly line chart y-axis prints in order it is read from CSV rather than sequentially 如何按数字顺序而不是基于 y 轴值绘制熊猫条形图的 x 轴 - How to plot the x-axis of a pandas bar plot in numerical order rather than based on y-axis value 以每月日期增量注释 matplotlib 热图 y 轴刻度 - Annotating matplotlib heatmap y-axis ticks in monthly date increments 为什么“和”排除其中包含0的任何对(x,y),而不仅仅是排除两者均为0的那对? - Why is “and” excluding any pairs (x,y) that have a 0 in them, rather than just excluding the one where both are 0? 标准化直方图 y 轴大于 1 - Normed histogram y-axis larger than 1 在图形X轴上显示月而不是天 - Display months rather than days on a graph X axis 如何在 python 中使用字符串轴而不是 integer 混淆矩阵 plot - How to plot confusion matrix with string axis rather than integer in python 为什么这个 Plotly 图形在 Y 轴和 X 轴上悬停? - Why is this Plotly graph is hovering Y and X axis? matplotlib:为什么我的Y轴失真? - matplotlib: Why is my Y-Axis distorting?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM