What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-16 11:06:19
how to set axis range matplotlib
# For a given y=time-dependent variable, x=time fig, ax = plt.subplots(figsize=(12, 6)) ax.plot(y, label='y') #'lower' is lower limit of the range you wanna set #'upper' is upper limit of the range you wanna set plt.xlim(lower, upper) Add solution -
Python 2021-11-15 14:14:28
this figure includes axes that are not compatible with tight_layout, so results might be incorrect
fig, ax = plt.subplots() fig.set_tight_layout(False) X = np.linspace(-np.pi, np.pi, 256,endpoint=True) C,S = np.cos(X), np.sin(X) ax.plot(X,C) ax.plot(X,S) plt.show() Add solution -
Other 2021-11-15 09:11:18
visualizing logistic regression separator plane
f, ax = plt.subplots(figsize=(8, 6)) ax.contour(xx, yy, probs, levels=[.5], cmap="Greys", vmin=0, vmax=.6) ax.scatter(X[100:,0], X[100:, 1], c=y[100:], s=50, cmap="RdBu", vmin=-.2, vmax=1.2, edgecolor="white... 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