使python的matplotlib图形看起来像使用OriginPro创建的图形 [英] Making python's matplotlib graphics look like graphics created using OriginPro
问题描述
我可能创建了一个副本,但在任何线程中都找不到我正在寻找的内容.我使用OriginPro 8.5G创建了图形,并且不能完全使用matplotlib重新创建图形.我对使用mpl设置图形样式很陌生,但是我会附上我已经尝试过的内容并显示一些图片.
I may have created a duplicate, but could not find exactly what I was looking for in any thread. I created graphics using OriginPro 8.5G and can not quite re-create them using matplotlib. I am quite new to styling graphics using mpl, but I will attach, what I have already tried and show some pictures.
使用OriginPro 8.5G创建的图
使用matplotlib.pyplot创建的图创建的图>
使用的代码如下:
import matplotlib as mpl
from matplotlib import rcParams, cycler
import matplotlib.pyplot as plt
from matplotlib.pyplot import plot, show
rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = ['Arial', 'Helvetica', 'Verdana', 'DejaVu Sans']
rcParams['font.size'] = 15
rcParams['axes.linewidth'] = 1.1
rcParams['axes.labelpad'] = 5.0
plot_color_cycle = cycler('color', ['000000', '0000FE', 'FE0000', '008001', 'FD8000', '8c564b', 'e377c2', '7f7f7f', 'bcbd22', '17becf'])
rcParams['axes.prop_cycle'] = plot_color_cycle
rcParams['axes.xmargin'] = 0
rcParams['axes.ymargin'] = 0
for ion in range(1, output_array_size_x):
plt.scatter(output_array[:,0], output_array[:,ion], marker='D')
plt.ylabel('Normalized signal intensity')
plt.xlabel('Excitation voltage [eV]')
plt.show()
其中 output_array_size_x
对于我的输入文件是可变的,但在这种情况下,它是 3
.
Where output_array_size_x
is variable with my input files, but in this case it is 3
.
我要具体做什么:
-
我希望标记物不被填充并且是透明的,例如原始图形的示例
I would like the marker to be non-filled and see-through, as in the example of the Origin graphic
边距/边距在理想情况下应与原始图形中的相同
The margins/ paddings should ideally be the same as in the Origin graphic
y轴和x轴的起点应恰好为0.0,且不应稍高于
y- and x-axis should begin at exactly 0.0 and not slightly above
output_array看起来像这样:
0.000000000000000000e+00 9.613190459262268561e-01 3.513449460836592236e-02 3.546459465407208068e-03
1.500000000000000000e+00 9.344751080827480294e-01 6.157866582480509693e-02 3.946226092446923107e-03
3.000000000000000000e+00 8.794867691496672801e-01 1.158346590855604402e-01 4.678571764772331693e-03
4.500000000000000000e+00 7.778204354741402593e-01 2.161575165907969054e-01 6.022047935062798014e-03
6.000000000000000000e+00 6.237757882444531221e-01 3.677228493577267554e-01 8.501362397820164118e-03
7.500000000000000000e+00 4.352079352079352148e-01 5.524160524160524055e-01 1.237601237601237622e-02
9.000000000000000000e+00 3.037328226321271418e-01 6.814501226354869878e-01 1.481705473238584779e-02
1.050000000000000000e+01 1.979494349295118361e-01 7.804380752650588171e-01 2.161248980542933643e-02
1.200000000000000000e+01 1.991559485530546569e-01 7.682877813504823683e-01 3.255627009646302333e-02
1.300000000000000000e+01 2.117732033224991040e-01 7.502347417840375954e-01 3.799205489346334230e-02
1.200000000000000000e+01 1.737333926641662918e-01 7.915580700527620195e-01 3.470853728307164016e-02
1.050000000000000000e+01 2.083233790434325661e-01 7.730899708538391257e-01 1.858665010272827350e-02
9.000000000000000000e+00 2.918319459187664333e-01 6.940052516900385715e-01 1.416280239119503855e-02
7.500000000000000000e+00 4.381243063263041138e-01 5.503408910734104431e-01 1.153480260028539803e-02
6.000000000000000000e+00 6.196725291324989282e-01 3.727206517047906842e-01 7.606819162710401483e-03
4.500000000000000000e+00 7.784601309988418150e-01 2.166833740474359837e-01 4.856494953722177016e-03
3.000000000000000000e+00 8.823418723003891850e-01 1.136723260488388954e-01 3.985801650771928287e-03
1.500000000000000000e+00 9.367085677246105302e-01 6.041314597464329805e-02 2.878286300746193873e-03
0.000000000000000000e+00 9.603569624515911896e-01 3.714430038727058181e-02 2.498737161138238610e-03
如果需要任何其他信息,请告诉我!帮助将不胜感激.
If any further information is required, let me know! Help would greatly be appreciated.
推荐答案
我认为以下内容大致等同于Origin图.不幸的是,并非所有内容都可以通过rcParams来确定,例如限制和次刻度位置.另外,我将 scatter
更改为 plot
,这样更容易获得空心标记.
I think the following is roughly the equivalent to the Origin figure.
Unfortunately, not everything can be determined via rcParams, such as the limits and the minor tick locations. Also I changed scatter
to plot
, which makes it easier to get hollow markers.
from matplotlib import rcParams, cycler
import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator
rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = ['Arial']
rcParams['font.size'] = 16
rcParams['axes.linewidth'] = 1.1
rcParams['axes.labelpad'] = 10.0
plot_color_cycle = cycler('color', ['000000', '0000FE', 'FE0000', '008001', 'FD8000', '8c564b',
'e377c2', '7f7f7f', 'bcbd22', '17becf'])
rcParams['axes.prop_cycle'] = plot_color_cycle
rcParams['axes.xmargin'] = 0
rcParams['axes.ymargin'] = 0
rcParams.update({"figure.figsize" : (6.4,4.8),
"figure.subplot.left" : 0.177, "figure.subplot.right" : 0.946,
"figure.subplot.bottom" : 0.156, "figure.subplot.top" : 0.965,
"axes.autolimit_mode" : "round_numbers",
"xtick.major.size" : 7,
"xtick.minor.size" : 3.5,
"xtick.major.width" : 1.1,
"xtick.minor.width" : 1.1,
"xtick.major.pad" : 5,
"xtick.minor.visible" : True,
"ytick.major.size" : 7,
"ytick.minor.size" : 3.5,
"ytick.major.width" : 1.1,
"ytick.minor.width" : 1.1,
"ytick.major.pad" : 5,
"ytick.minor.visible" : True,
"lines.markersize" : 10,
"lines.markerfacecolor" : "none",
"lines.markeredgewidth" : 0.8})
for ion in range(1, output_array_size_x):
plt.plot(output_array[:,0], output_array[:,ion], marker='D', ls="none")
plt.xlim(0, 13)
plt.ylim(0, None)
plt.ylabel('Normalized signal intensity')
plt.xlabel('Excitation voltage [eV]')
plt.gca().xaxis.set_minor_locator(AutoMinorLocator(n=2))
plt.gca().yaxis.set_minor_locator(AutoMinorLocator(n=2))
plt.savefig("out.png", dpi=1000)
plt.show()
这篇关于使python的matplotlib图形看起来像使用OriginPro创建的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!