2015-11-05 49 views
1

我嘗試了幾個小時來更改默認白色背景黑色標籤/軸時,繪製與sunpy黑色背景&白色標籤/軸。更改sunpy/pyplot顏色

基本上我想...

ax = sunpy_map.plot() 
sunpy_map.draw_limb() 
# somehow change label/text/limb etc. to white 
plt.savefig(get_image_name(bin, flare_id), bbox_inches='tight', facecolor='black', edgecolor='black') 

我嘗試過很多事情,但還沒有找到一個解決辦法。任何幫助將非常感謝!

+0

你的意思*整個*背景黑色(而不僅僅是在軸內)? – SiHa

+0

是,像這樣的圖像:http://hsp.cs.technik.fhnw.ch/flaredata/15011115/3848/coarse/3_1136957982.8165888786315918_131_visclean_photon.png – Doidel

回答

1

由於SunPy使用Matplotlib來完成其繪圖任務,你也許可以完成你想要的修改matplotlibrc(請注意,我不能SunPy測試此):

import matplotlib 
from matplotlib import pyplot as plt 

matplotlib.rc('savefig', facecolor='black') 
matplotlib.rc('axes', edgecolor='white') 
matplotlib.rc('xtick', color='white') 
matplotlib.rc('ytick', color='white') 
matplotlib.rc('axes', labelcolor='white') 
matplotlib.rc('axes', facecolor='black') 

plt.plot([0, 1], [0, 1]) 
plt.savefig('test.png') 

enter image description here

+0

這改變http://s11.postimg.org/4r8wnfwoz/plotwhite .png到http://s11.postimg.org/6hrxoxe83/plotblack.png。即顏色條的標籤是白色的,沒有其他的東西,我也不確定你的解決方案是否覆蓋了四肢。但是,謝謝了! – Doidel

+0

@Doidel也許你正在重寫代碼中其他地方的這些新的默認值? (例如,上面有'edgecolor ='Black'')。不,它不包括繪製的肢體,因爲您只提到背景和軸/標籤。你還需要情節本身嗎? – SiHa

+0

它的工作原理!謝謝大家^^ 我不知道是什麼讓它工作到最後,我現在用'fig = plt.figure(); ax = plt.subplot(); sunpy_map.plot()'然後繪製它。但最後你的方法對我有用,非常感謝! – Doidel