2016-10-26 9 views
1

xおよびyラベルの太字フォントを取得するにはどうすればよいですか。 pltにはweight='bold'を使用しましたが、ホストでは動作しません。縦と横の軸のラベルを太字またはフォントに設定する方法

from mpl_toolkits.axes_grid1 import host_subplot 
import mpl_toolkits.axisartist as AA 

if 2: 
    host = host_subplot(111, axes_class=AA.Axes) 
    plt.subplots_adjust(right=0.75) 
    par1 = host.twinx() 
    par2 = host.twinx() 
    offset = 60 
    new_fixed_axis = par2.get_grid_helper().new_fixed_axis 
    par2.axis["right"] = new_fixed_axis(loc="right", 
             axes=par2, 
             offset=(offset, 0)) 
    par2.axis["right"].toggle(all=True) 
    host.set_xlim(1, 9) 
    host.set_ylim(200,1100) 
    host.set_xlabel('Station Number [-]', weight='bold') 
    host.set_ylabel('Temperature [K]', weight='bold') 
    par1.set_ylabel('Pressure [kPa]', weight='bold') 
    par2.set_ylabel("Mass flow rate [kg/s]", weight='bold') 
    p1, = host.plot(Station, Total_temperature,'k-*',label="Total Temperature",ms=8,mew=2,mfc='w',linewidth=2) 
    p1, = host.plot(Station, Static_temperature, 'k--o',label="Static Temperature",ms=8,mew=2,linewidth=2) 
    p2, = par1.plot(Station, Total_pressure, 'k-v',label="Total Pressure",ms=8,mew=2,mfc='w',linewidth=2) 
    p2, = par1.plot(Station, Static_pressure,'k--d',label="Static Pressure",ms=8,mew=2,linewidth=2) 
    p3, = par2.plot(Station, Mass_flow,'k-x',label="Mass Flow Rate",ms=8,mew=2,mfc='w',linewidth=2) 
    plt.grid() 
    par1.set_ylim(40,400) 
    par2.set_ylim(0.287,0.294) 
    host.legend(prop={'size':12}, loc='center right') 
    #legend1 = host.legend(('Total Temperature', 'Static Temperature', 'Mass Flow Rate'),'upper right', prop={'size':13}) 
    #plt.legend(('Total Pressure','Static Pressure'),'lower right',prop={'size':13}) 
    #plt.gca().add_artist(legend1) 
    host.axis["left"].label.set_color(p1.get_color()) 
    par1.axis["right"].label.set_color(p2.get_color()) 
    par2.axis["right"].label.set_color(p3.get_color()) 
    plt.savefig('Stations.svg') 
    plt.draw() 
    plt.show() 

答えて

1

fontdictキーワード辞書の内部ではなく、スタンドアロンのキーワード引数として渡す必要があるweight='bold'axes.set_xlabel/axes.set_ylabelのフォントプロパティを変更します。たとえば、次のように

import matplotlib.pyplot as plt 

fig, ax = plt.subplots() 
ax.set_xlabel('xlabel', fontdict=dict(weight='bold')) 

plt.show() 

enter image description here

関連する問題