python绘制双y轴坐标轴的图
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
%matplotlib inline
time = np.linspace(1,16,16)
ranksum1=[0.013113572066554608,0.007277342460741646,0.001865617255167422,0.09793058424531026,0.0003303138280078064,0.01242546 6409185966,0.007299353536739003,0.0016887057672722511,0.033420556865445906,0.0017448706429642044,3.440067218871153e-05,0.0021 16634065643658,0.08445415973492687,0.0040360195543007555,0.00025778180700253186,0.0016403564335245172]
linspace numpy
ranksum2 =[0.024128394025773815,0.02007083349028568,0.0008787907090327508,0.07989054842381477,0.0013124193106560248,0.1940516 4585951518,0.0342773636550135,0.003841386996789588,0.09100454307986566,0.013806782961975418,5.9523396990788154e-06,0.00971249 381863995,0.095619847709978,0.0064011054890893175,0.00027980082053763537,0.00098544194721545]
fig = plt.figure(figsize=(6,4))
ax = fig.add_subplot(111)
ax.plot(time, ranksum1,'mx', markersize=10,markeredgewidth=3.5)#color:magenta shape:x
ax.axhline(y=0.05, color='magenta', linestyle='--')
#刻度设置
x_tick = np.linspace(1,16,4)
for i in range(1,17):
ax.axvline(i,linestyle='--',color='orange',linewidth=0.5)
labels = ax.get_yticklabels()
[label.set_fontname('Verdana')for label in labels]
#第⼆个坐标轴
ax2 = ax.twinx()
ax2.plot(time, ranksum2,'cv',markersize=10,markeredgewidth=2.5)#color='cyan'
ax2.axhline(y=0.05, color='cyan', linestyle='--')
#刻度设置
x_tick = np.linspace(1,16,4)
y_tick = np.linspace(0,0.2,6)
labels = ax.get_yticklabels()
[label.set_fontname('Verdana')for label in labels]
font2 ={'family':'Verdana','weight':'normal','size':29.5,'color':'#000000'}
ax.set_xlabel('x',font2)
ax.set_ylabel('y1',font2)
ax2.set_ylabel('y2',font2)
plt.tight_layout()
plt.savefig('G:/1.png',dpi=1500,bbox_inches='tight')#,bbox_inches='tight'
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论