更改轴样式python [英] Change axis style python

查看:46
本文介绍了更改轴样式python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 python 绘制一个指数衰减的 cos 曲线的简单图.下面的代码,实际运行的代码没有问题,我只是想知道是否有一种方法可以更改python显示图形的方式,而不是被诸如this 它有像

I'm making a simple plot of an exponentially decaying cos curve in python. The code is below, there's no problem with the code actually running, I was just wondering if there's a way to change the way python displays the graph so rather than being enclosed by the axes like this it has the axes like this. It's not an urgent problem, it's just to make the plot match more closely with other parts of my report.

import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
t = np.linspace(0, 4, 10000)
r=1
x = t
y = r * np.exp(-t)*np.cos(10*t)

plt.plot(x,y,'-')
plt.plot(x,np.zeros(10000),'k-')
plt.show()

推荐答案

看看轴matplotlib画廊中的线条样式演示.

具体来说,这些行:

ax = SubplotZero(fig, 111)

...

for direction in ["left", "right", "bottom", "top"]: 
    ax.axis[direction].set_visible(False)

这篇关于更改轴样式python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆