What do you want to save?
Add Code snippet
New code examples
-
Other 2021-10-09 22:15:13
matplotlib hover event
x = np.random.rand(15) y = np.random.rand(15) names = np.array(list("ABCDEFGHIJKLMNO")) c = np.random.randint(1,5,size=15) norm = plt.Normalize(1,4) cmap = plt.cm.RdYlGn fig,ax = plt.subplots() sc = plt.scatter(x,y,c=c, s=100, cmap=cmap, norm=... Add solution -
Python 2021-10-08 05:13:03
trends in yearly data python
import matplotlib.pyplot as pltimport matplotlib.dates as mdatesfig, ax = plt.subplots()ax.grid(True)year = mdates.YearLocator(month=1)month = mdates.MonthLocator(interval=3)year_format = mdates.DateFormatter('%Y')month_format = mdates.DateFormatter('%m')... Add solution -
Python 2021-10-05 07:34:04
how to change the colour of axes in matplotlin
import matplotlib.pyplot as plt with plt.rc_context({'axes.edgecolor':'orange', 'xtick.color':'red', 'ytick.color':'green', 'figure.facecolor':'white'}): # Temporary rc parameters in effect fig, (ax1, ax2) = plt.subplots(1,2) ax1.plot(range(10... Add solution -
Python 2021-10-05 03:19:02
python decrease gap between subplot rows
# Short answer: # If you have too much white space between rows (or columns) of a figure # with subplots, you can either shrink the vertical (or horizontal) # dimensions of the figure with figsize so that they get more "squished" # together, or... Add solution -
Other 2021-10-04 05:27:02
multiple bars barchart matplotlib
ax = plt.subplot(111) w = 0.3 ax.bar(x-w, y, width=w, color='b', align='center') ax.bar(x, z, width=w, color='g', align='center') ax.bar(x+w, k, width=w, color='r', align='center') ax.xaxis_date() ax.autoscale(tight=True) plt.show() Add solution -
Python 2021-09-28 23:00:03
y =mx+c trend analysis in for a column of dataframe
import matplotlib.pyplot as pltimport matplotlib.dates as mdatesfig, ax = plt.subplots()ax.grid(True)year = mdates.YearLocator(month=1)month = mdates.MonthLocator(interval=3)year_format = mdates.DateFormatter('%Y')month_format = mdates.DateFormatter('%m')... Add solution -
Python 2021-09-26 01:33:04
matplotlib get and chan values of tick labels
import matplotlib.pyplot as plt fig, ax = plt.subplots() # We need to draw the canvas, otherwise the labels won't be positioned and # won't have values yet. fig.canvas.draw() labels = [item.get_text() for item in ax.get_xticklabels()] labels[1] = 'Tes... Add solution -
Python 2021-09-25 13:01:03
animate time series python
import numpy as np import matplotlib.pyplot as plt from matplotlib import animation dt = 0.01 tfinal = 1 x0 = 0 sqrtdt = np.sqrt(dt) n = int(tfinal/dt) xtraj = np.zeros(n+1, float) trange = np.linspace(start=0,stop=tfinal ,num=n+1) xtraj[0] = x0 for i ... Add solution