Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

subplots in subplots

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

fig = plt.figure(figsize=(10, 8))
outer = gridspec.GridSpec(2, 2, wspace=0.2, hspace=0.2)

for i in range(4):
    inner = gridspec.GridSpecFromSubplotSpec(2, 1,
                    subplot_spec=outer[i], wspace=0.1, hspace=0.1)

    for j in range(2):
        ax = plt.Subplot(fig, inner[j])
        t = ax.text(0.5,0.5, 'outer=%d, inner=%d' % (i, j))
        t.set_ha('center')
        ax.set_xticks([])
        ax.set_yticks([])
        fig.add_subplot(ax)

fig.show()
Comment

subplots

# new style method 1; unpack the axes
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, sharey=True)
ax1.plot(x)
Comment

subplot

# Build the plot
fig, ax = plt.subplots()
ax.bar(x_pos, CTEs, yerr=error, align='center', alpha=0.5, ecolor='black', capsize=10)
ax.set_ylabel('Coefficient of Thermal Expansion ($degree C^{-1}$)')
ax.set_xticks(x_pos)
ax.set_xticklabels(materials)
ax.set_title('Coefficent of Thermal Expansion (CTE) of Three Metals')
ax.yaxis.grid(True)

# Save the figure and show
plt.tight_layout()
plt.savefig('bar_plot_with_error_bars.png')
plt.show()
Comment

subplot

subplot(m,n,p)	%Creates subplot of m rows and n columns and assigns to plot in
p index of mxn subplot matrix.
Comment

subplots

fig, (ax1, ax2,ax3,ax4,ax5) = plt.subplots(1,5)

# Whatever you want your values to be:-
ax1.plot([1,2,3,4,5], [1,2,3,4,10], 'go')
ax2.plot([1,2,3,4,5], [2,3,4,5,11], 'b*') 


#X labels:-

ax1.set_xlabel('whatever you want')  
ax2.set_xlabel('whatever you want')
ax3.set_xlabel('whatever you want')
ax4.set_xlabel('whatever you want')
ax5.set_xlabel('whatever you want')
#You can do same with Y axis
Comment

PREVIOUS NEXT
Code Example
Python :: pandas switch column levels 
Python :: django strptime 
Python :: python class without init 
Python :: select statement python 
Python :: from random input python 
Python :: python redis delete many 
Python :: python xmlrpc 
Python :: guessing game python 
Python :: A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. 
Python :: windows instalar python 
Python :: os.filename 
Python :: pysimplegui get value from textbox 
Python :: python get module name 
Python :: install python package 
Python :: escape brackets in regex python 
Python :: not using first row as index pandas 
Python :: Python NumPy delete Function Syntax 
Python :: Convert csv to dictionary in Python 
Python :: Convert a Pandas Column of Timestamps to Datetimes 
Python :: division in python 
Python :: model checkpoint 
Python :: generate python 
Python :: if in python 
Python :: python how to create a function 
Python :: negative slicing in python 
Python :: Label enconding code with sklearn 
Python :: python tkinter focus on entry 
Python :: python while loop 
Python :: python strip function 
Python :: python - input: integer 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =