python - How to make matplotlib graphs look professionally done like this? -


default matplotlib graphs unattractive , unprofessional. tried out couple of packages include seaborn prettyplotlib both of these barely improves styles.

so far i've gotten following using seaborn package:

enter image description here

below appearance i'm looking far cry above:

enter image description here

notice following niceness in 2nd example:

  1. area under graph filled more eye pleasing color.
  2. the graph line thinker , nicely stands out.
  3. axis lines thinker , again nicely stands out.
  4. area under curve transparent.
  5. x-axis tick marks more denser.

my questions are: recognize above kind of popular theme or style can use in matplotlib? or if can use package? failing that, there anyway set style global preference? failing that, possible in matlibplot?

thanks!

this matter of taste, , matter of target audience. matplotlib tries produce clear illustrations scientific purposes. - - compromise, , illustrations not print in magazine or show in advertisement.

there news , bad news matplotlib in sense.

bad news:

  • there no single magical command or package create beautiful plots matplotlib.

good news:

in opinion difficult thing decide want. doing want easier, though there steepish learning curve in beginning.

just example:

import numpy np import matplotlib.pyplot plt   # create fictive access data hour xdata = np.arange(25) ydata = np.random.randint(10, 20, 25) ydata[24] = ydata[0]  # let make simple graph fig = plt.figure(figsize=[7,5]) ax = plt.subplot(111) l = ax.fill_between(xdata, ydata)  # set basic properties ax.set_xlabel('time of posting (us est)') ax.set_ylabel('percentage of frontpaged submissions') ax.set_title('likelihood of reaching frontpage')  # set limits ax.set_xlim(0, 24) ax.set_ylim(6, 24)  # set grid on ax.grid('on') 

(just comment: x-axis limits in original image not take cyclicity of data account.)

this give this:

enter image description here

it easy understand need lot of changes in order able show less-engineering-minded audience. @ least:

  • make fill transparent , less offensive in colour
  • make line thicker
  • change line colour
  • add more ticks x axis
  • change fonts of titles

# change fill blueish color opacity .3 l.set_facecolors([[.5,.5,.8,.3]])  # change edge color (bluish , transparentish) , thickness l.set_edgecolors([[0, 0, .5, .3]]) l.set_linewidths([3])  # add more ticks ax.set_xticks(np.arange(25)) # remove tick marks ax.xaxis.set_tick_params(size=0) ax.yaxis.set_tick_params(size=0)  # change color of top , right spines opaque gray ax.spines['right'].set_color((.8,.8,.8)) ax.spines['top'].set_color((.8,.8,.8))  # tweak axis labels xlab = ax.xaxis.get_label() ylab = ax.yaxis.get_label()  xlab.set_style('italic') xlab.set_size(10) ylab.set_style('italic') ylab.set_size(10)  # tweak title ttl = ax.title ttl.set_weight('bold') 

now have:

enter image description here

this not in question, can tuned towards direction. many of things set here can set defaults matplotlib. maybe gives idea of how change things in plots.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

php - Warning: file_get_contents() expects parameter 1 to be a valid path, array given 16 -

VBA function to include CDATA -