python交互式怎么保存_Matplotlib设置,用于保存要发布的图形和交互式绘图中的报告...

我编写了一个python函数来获取当前任何交互式图形,并修改标签和刻度标签的文本大小。然后移除顶部和右侧轴,以获得更为首选的图形格式输出。然后输出数字。我遇到的问题是如何设置轴的大小,以便xlabel被保存在图形的画布上,以便当输出显示出来时。我知道手动创建轴时可以执行以下操作:ax = plt.axes([0.125,0.2,0.95-0.125,0.95-0.2])

有没有办法在绘图后设置这些参数?如果是这样,我如何获得访问权或着手修改它?(也可以在matplotlibrc文件中设置吗?)。在

另一个问题与人物是否有图例有关:

我通常使用这组图例参数,但在之后如何设置其他规范?我只发现了下面这些:

^{pr2}$

带辅助功能的完整绘图功能:def plot_for_publication_output(fig, ax, filename, dir_addition='',

fulldir=None, column_width=1, dpi=600,

out_formats=['.eps','.pdf','.png']):

"""

column_width assumes a standard 2 column width format (default 1 column,

2 meaning spreads across both columns)

"""

if fulldir == None:

store_dir = os.path.expanduser('~/'+'Dropbox/Research/Results/' + dir_addition)

else:

store_dir = fulldir

spineLineWidth = 0.5

tick_size = 9

fontlabel_size = 10.5

mydpi = dpi

outExt = out_formats

dashs = ['-.', '-', '--', ':']

dashes = [(1.5, 0), (3.5, 1.5), (1.5, 1.5, 3,1.5), (1, 1)]

plot_color = "bgrkcykw"

fig_width_pt = 246.0 * column_width # Get this from LaTeX using

# \showthe\columnwidth

inches_per_pt = 1.0 / 72.27 # Convert pt to inches

golden_mean = (np.sqrt(5) - 1.0) / 2.0 # Aesthetic ratio

fig_width = fig_width_pt * inches_per_pt # width in inches

fig_height = fig_width * golden_mean # height in inches

fig.set_size_inches(fig_width, fig_height)

plotSetAxisTickLabels(ax, tick_size)

plotSetAxisLabels(ax, fontlabel_size)

#params = {'axes.labelsize': fontlabel_size, 'text.fontsize': fontlabel_size,

# 'legend.fontsize': fontlabel_size, 'xtick.labelsize': tick_size,

# 'ytick.labelsize': tick_size, 'text.usetex': True,

# 'figure.figsize': fig_size}

#plt.rcParams.update(params)

#ax = plt.axes([0.125, 0.2, 0.95 - 0.125, 0.95 - 0.2])

set_spineLineWidth(ax,spineLineWidth)

clear_spines(ax)

ax.yaxis.set_ticks_position('left')

ax.xaxis.set_ticks_position('bottom')

for i in outExt:

plt.savefig(os.path.join(store_dir, filename) + i, dpi = mydpi)

def clear_spines(ax):

ax.spines['top'].set_color('none')

ax.spines['right'].set_color('none')

def set_spineLineWidth(ax, lineWidth):

for i in ax.spines.keys():

ax.spines[i].set_linewidth(lineWidth)

def showOnlySomeTicks(x, pos):

s = str(int(x))

if x == 5000:

return '5e3'#'%.0e' % x

return ''

def plotSetAxisTickLabels(ax, size=16):

for i in ax.xaxis.get_ticklabels():

i.set_fontsize(size)

for i in ax.yaxis.get_ticklabels():

i.set_fontsize(size)

def plotSetAxisLabels(ax, size=16):

ax.xaxis.get_label().set_fontsize(size)

ax.yaxis.get_label().set_fontsize(size)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值