What do you want to save?
Add Code snippet
New code examples
-
Python 2022-02-11 10:25:01
quadratic equation plot in python
import matplotlib.pyplot as plt import numpy as np # 100 linearly spaced numbers x = np.linspace(0,1,10) eta1=0.05 eta2=0.1 lmd1= 2.8 # the function, which is y = x^2 here y = 0.5*(-(1/3)*eta1*x**2 + np.sqrt( ((1/3)*eta1*x**2)**2-4*(3*x**2*2.8**2-1)) #... Add solution -
Python 2022-02-09 19:35:06
pyplot second y axis
import numpy as np import matplotlib.pyplot as plt # Create some mock data t = np.arange(0.01, 10.0, 0.01) data1 = np.exp(t) data2 = np.sin(2 * np.pi * t) fig, ax1 = plt.subplots() color = 'tab:red' ax1.set_xlabel('time (s)') ax1.set_ylabel('exp', colo... Add solution -
Python 2022-02-06 06:30:30
python how to add a figure legend at the best position
# Short answer: # matplotlib.pyplot places the legend in the "best" location by default # To add a legend to your plot, call plt.legend() # Example usage: import matplotlib.pyplot as plt x1 = [1, 2, 3] # Invent x and y data to be plotted y1 = [... Add solution -
Python 2022-02-02 22:11:23
matplotlib histogram python
import matplotlib.pyplot as plt data = [1.7,1.8,2.0,2.2,2.2,2.3,2.4,2.5,2.5,2.5,2.6,2.6,2.8, 2.9,3.0,3.1,3.1,3.2,3.3,3.5,3.6,3.7,4.1,4.1,4.2,4.3] #this histogram has a range from 1 to 4 #and 8 different bins plt.hist(data, range=(1,4), bins=8) plt... Add solution -
Other 2022-02-02 19:45:38
matplotlib join axes
import matplotlib.pyplot as plt fig, axs = plt.subplots(ncols=3, nrows=3) gs = axs[1, 2].get_gridspec() # remove the underlying axes for ax in axs[1:, -1]: ax.remove() axbig = fig.add_subplot(gs[1:, -1]) axbig.annotate('Big Axes \nGridSpec[1:, -1]', ... Add solution -
Python 2022-02-02 06:06:04
matplotlib animation
import matplotlib.pyplot as plt from matplotlib import cm import numpy as np from celluloid import Camera numpoints = 10 points = np.random.random((2, numpoints)) colors = cm.rainbow(np.linspace(0, 1, numpoints)) camera = Camera(plt.figure()) for _ in ra... Add solution -
Other 2022-02-01 22:36:47
fibonacci sphere python
from numpy import pi, cos, sin, arccos, arange import mpl_toolkits.mplot3d import matplotlib.pyplot as pp num_pts = 1000 indices = arange(0, num_pts, dtype=float) + 0.5 phi = arccos(1 - 2*indices/num_pts) theta = pi * (1 + 5**0.5) * indices x, y, z = c... Add solution -
Python 2022-02-01 14:12:26
k means clustering python medium
import pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport numpy as np# read data into variable Iris_dataIris_data = pd.read_csv("D:\ProjectData\Iris.csv")#display first few rows of dataIris_data.head() Add solution