本文摘自php中文网,作者小云云,侵删。
在使用matplotlib模块时画坐标图时,往往需要对坐标轴设置很多参数,这些参数包括横纵坐标轴范围、坐标轴刻度大小、坐标轴名称等 ,在matplotlib中包含了很多函数,用来对这些参数进行设置。我们可以对坐标轴进行设置,设置坐标轴的范围,设置坐标轴上的文字描述等。本文我们将和大家介绍python matplotlib坐标轴设置的方法。基本用法
例如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
x = np.linspace( - 1 , 1 , 50 )
y1 = 2 * x + 1
y2 = x * * 2
plt.xlim( - 1 , 2 )
plt.ylim( - 1 , 3 )
plt.xlabel( "I am x" )
plt.ylabel( "I am y" )
plt.plot(x, y2)
plt.plot(x, y1, color = 'red' , linewidth = 1.0 , linestyle = '--' )
plt.show()
|
阅读剩余部分
相关阅读 >>
Python图像保存在哪里
读懂Python的异常机制
Python怎么统计文本中的字频
Python中divmod是什么
Python如何遍历文件夹
用pip升级所有包怎么操作
spark能跑Python么
Python扩展内置类型的实现方法分析
Python输出怎么取消空格
了解Python 中日志异步发送到远程服务器
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python matplotlib坐标轴设置的方法