Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 在y轴上有断点的多个数据集打印_Python 2.7_Matplotlib - Fatal编程技术网

Python 2.7 在y轴上有断点的多个数据集打印

Python 2.7 在y轴上有断点的多个数据集打印,python-2.7,matplotlib,Python 2.7,Matplotlib,我可以在一个绘图中绘制多个数据集,也可以在y轴()上分别绘制具有单个数据集的绘图。但是我想做的是在下面的图中删除从10^46到10^58的部分。!我用来绘制的代码是 from numpy import * from pylab import * from matplotlib import rc, rcParams import matplotlib.pyplot as plt import numpy as np rc('text',usetex=True) rc('font',**{'fa

我可以在一个绘图中绘制多个数据集,也可以在y轴()上分别绘制具有单个数据集的绘图。但是我想做的是在下面的图中删除从10^46到10^58的部分。!我用来绘制的代码是

from numpy import *
from pylab import *
from matplotlib import rc, rcParams
import matplotlib.pyplot as plt
import numpy as np

rc('text',usetex=True)
rc('font',**{'family':'serif','serif':['Computer Modern']})

x_1=np.linspace(5e13, 8e14, 201)
z = np.linspace(0, np.pi, 201)
y_1 =np.cos(z)*1e43
x_2=np.linspace(5e13, 1e15, 201)
y_2 =np.cos(z)*1e61
x_3=np.linspace(3e13, 1e15, 201)
y_3 =np.tan(z)*1e63

run_1,=plt.plot(x_1, y_1, '.b') 
run_2,=plt.plot(x_2, y_2, '.g') 
run_3,=plt.plot(x_3, y_3,'.r') 

plt.yscale('log')
plt.xscale('log')
plt.xlim([40000000000000,2000000000000000])


plt.legend((run_1, run_2,run_3), ('CR Flux','Gas Ensrgy','Total Energy'),scatterpoints=1, loc='lower right', ncol=1, fontsize=12)

# Turn on a grid
grid(True)
savefig('camp_line.png')
show() 

如何做到这一点?有什么函数可以实现这一点吗?

您可以减少这里的代码量吗?这个示例对您不适用吗?另外,请您编辑您的示例,以便其他人可以运行它(即,生成一些虚假但适当的数据,而不是读取文件,例如,
x=np.linspace(5e13,8e14,1000);y=1e43+10*sin(x)
)。@tom10正如您建议的,我编辑了该程序。示例matplotlib.org/examples/pylab_examples/breaked_axis.html对我不起作用。@代码量已经减少了。@RSJohn:为什么示例对你不起作用?