What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-02 12:20:01
significant figures on axes plot matplotlib
import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import FormatStrFormatter fig, ax = plt.subplots() ax.yaxis.set_major_formatter(FormatStrFormatter('%g')) ax.yaxis.set_ticks(np.arange(-2, 2, 0.25)) x = np.arange(-1, 1, 0.1) plt... Add solution -
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-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-01-26 00:01:21
matplotlib: use colormaps for line plot colors
import numpy as np import matplotlib.pylab as plt plt.rcParams["figure.figsize"] = [7, 7] plt.rcParams["figure.autolayout"] = True x = np.array([0,1]) y = np.array([1,1]) n = 50 colors = plt.cm.hsv(np.linspace(0, 1, n)) for i in range(... Add solution -
Python 2022-01-24 01:55:39
xaxis matplotlib
import matplotlib.pyplot as plt x = [0.00001,0.001,0.01,0.1,0.5,1,5] # create an index for each tick position xi = list(range(len(x))) y = [0.945,0.885,0.893,0.9,0.996,1.25,1.19] plt.ylim(0.8,1.4) # plot the index for the x-values plt.plot(xi, y, marker='... Add solution