Ryan's Blog

Matplotlib: black background

Posted in research by ryanlayer on February 18, 2014


matplotlib.rcParams.update({'font.size': 12})
fig = matplotlib.pyplot.figure(figsize=(5,5),dpi=300,facecolor='black')
fig.subplots_adjust(wspace=.05,left=.01,bottom=.01)
ax = fig.add_subplot(1,1,1,axisbg='k')

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_linewidth(0.5)
ax.spines['left'].set_linewidth(0.5)
ax.spines['bottom'].set_color('white')
ax.spines['left'].set_color('white')

ax.title.set_color('white')
ax.yaxis.label.set_color('white')
ax.xaxis.label.set_color('white')
ax.tick_params(axis='x', colors='white')
ax.tick_params(axis='y', colors='white')

ax.tick_params(axis='both', direction='in')
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()

ax.set_xlabel('X-Axis Label Here')
ax.set_ylabel('Y-Axis Label Here')
ax.set_title('Title Here')

ax.plot(range(10),range(10),'.-',color='yellow',\
  linewidth=2,\
  markersize=12)

matplotlib.pyplot.savefig("dark.png",\
  bbox_inches='tight',\
  facecolor=fig.get_facecolor(),\
  transparent=True)

Here for a Matplotlib color names.

Advertisements
Tagged with: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: