python - matplotlib chart area vs plot area -


in matplotlib, how can control size of plot area vs total area of chart?

i set set size of chart area using following code:

fig = plt.gcf() fig.set_size_inches(8.11, 5.24) 

however, not know how set size of plot area , result when output chart, legend on x-axis comes out cut in half.

i think example can you. figure size figsize can set size of window plot inhabit. axes list parameters [left, bottom, width, height] determines in figure plot exist , how area covered.

so if run code below see window of size 8x6 inches. inside window main plot big_ax takes 0.8x0.8 of total area. there second plot small_ax of size 0.3x0.3 of total area.

import matplotlib.pyplot plt import numpy np  x1 = np.random.randint(-5, 5, 50) x2 = np.random.randn(20)  fig = plt.figure(figsize=(8,6))  # sets window 8 x 6 inches  # left, bottom, width, height (range 0 1) # think of width , height percentage of window size big_ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])  small_ax = fig.add_axes([0.52, 0.15, 0.3, 0.3]) # left, bottom, width, height (range 0 1)  big_ax.fill_between(np.arange(len(x1)), x1, color='green', alpha=0.3) small_ax.stem(x2)  plt.setp(small_ax.get_yticklabels(), visible=false) plt.setp(small_ax.get_xticklabels(), visible=false) plt.show() 

enter image description here


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -