i saving plots transparent background paste on dark background. can fix things, 2 things don't know how "brighten up" visible.
1) square box of axes each of plots in figure.
2) little black "1e11" thing.
i suppose i'd plots same if simpler, interest piqued if there way each separately (e.g. red border 1 plot, green another).
import matplotlib.pyplot plt import numpy np tau = 2.*np.pi theta = np.linspace(0, tau) x = 1.4e+11 + 0.9e+10 * np.cos(theta) y = 3.3e+10 + 4.5e+09 * np.sin(theta) fig = plt.figure(figsize=(10,5)) fig.patch.set_alpha(0.0) ax1 = fig.add_axes([0.08, 0.15, 0.4, 0.8]) ax2 = fig.add_axes([0.55, 0.15, 0.4, 0.8]) grey1 = (0.5, 0.5, 0.5) grey2 = (0.7, 0.7, 0.7) ax1.patch.set_facecolor(grey1) ax1.patch.set_alpha(1.0) ax1.set_xlabel('time (sec)', fontsize = 16, color=grey2) ax1.tick_params(axis='both', which='major', labelsize = 16, colors=grey2) ax1.plot(x, y) plt.savefig('nicefig') # don't need: transparent=true plt.show()
the simplest approach change default settings:
import matplotlib.pyplot plt import numpy np # define colors grey1 = (0.5, 0.5, 0.5) grey2 = (0.7, 0.7, 0.7) plt.rcparams['lines.color'] = grey2 plt.rcparams['xtick.color'] = grey2 plt.rcparams['ytick.color'] = grey2 plt.rcparams['axes.labelcolor'] = grey2 plt.rcparams['axes.edgecolor'] = grey2 # rest of code goes here ....
result:
however, apply changes axes. if want keep standard colors on ax2
, have dig axes object , find corresponding artists lines , text elements:
# plotting code goes here ... # change box color plt.setp(ax1.spines.values(), color=grey2) # change colors of ticks plt.setp([ax1.get_xticklines(), ax1.get_yticklines()], color=grey2) # change colors of labels plt.setp([ax1.xaxis.get_label(), ax1.yaxis.get_label()], color=grey2) # change color of tick labels plt.setp([ax1.get_xticklabels(), ax1.get_yticklabels()], color=grey2) # change color of axis offset texts (the 1e11 thingy) plt.setp([ax1.xaxis.get_offset_text(), ax1.yaxis.get_offset_text()], color=grey2) plt.show()
result:
Comments
Post a Comment