What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-13 07:19:18
python draw rectangle on image
img = matplotlib. image. imread("./kite_logo.png") figure, ax = pyplot. subplots(1) rect = patches. Rectangle((125,100),50,25, edgecolor='r', facecolor="none") ax. imshow(img) Displays an image. ax. add_patch(rect) Add rectangle to image. Add solution -
Python 2021-11-12 01:57:14
second y axis matplotlib
import numpy as np import matplotlib.pyplot as plt x = np.arange(0, 10, 0.1) y1 = 0.05 * x**2 y2 = -1 *y1 fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.plot(x, y1, 'g-') ax2.plot(x, y2, 'b-') ax1.set_xlabel('X data') ax1.set_ylabel('Y1 data', color='... Add solution -
Python 2021-11-09 22:16:08
multiple at-risk counts
from lifelines import KaplanMeierFitter from lifelines.datasets import load_waltons waltons = load_waltons() ix = waltons['group'] == 'control' ax = plt.subplot(111) kmf_control = KaplanMeierFitter() ax = kmf_control.fit(waltons.loc[ix]['T'], waltons.l... Add solution -
Python 2021-11-03 23:07:07
matplotlib secondary x axis
import matplotlib.pyplot as plt import numpy as np import datetime import matplotlib.dates as mdates from matplotlib.transforms import Transform from matplotlib.ticker import ( AutoLocator, AutoMinorLocator) fig, ax = plt.subplots(constrained_layout=... Add solution -
Python 2021-11-03 19:55:14
how to scatter plot in matplotlib of two sets
import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(111) ax1.scatter(x1, y1, s = 10, c = 'b', label = 'elbow') ax1.scatter(x2, y2, s = 10, c = 'r', label = 'shoulder') plt.legend(loc='upper left'); plt.show() Add solution
Best helpers
Rlw
+5
John Rualo
+5
Michael Wang
+5
Heavens
+5
Calvino
+5
Withparadox2
+5
SuzyTypehead
+5
Aj Morales
+5