What do you want to save?
Add Code snippet
New code examples
-
Python 2022-02-16 01:10:02
matplotlib plot two graphs side by side
import matplotlib.pyplot as plt import numpy as np # Simple data to display x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) # the container holding the two Axes have already been unpacked # useful if just few Axes have been created f, (ax1, ax2) ... Add solution -
Python 2022-02-15 20:00:08
how to plot side by side bar horizontal bar graph in python
import pandas import matplotlib.pyplot as plt import numpy as np df = pandas.DataFrame(dict(graph=['Item one', 'Item two', 'Item three'], n=[3, 5, 2], m=[6, 1, 3])) ind = np.arange(len(df)) width = 0.4 fig, ax = plt.subplots... 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-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 -
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 -
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 10:25:36
plot two axes plotly
import plotly.graph_objects as go from plotly.subplots import make_subplots # Create figure with secondary y-axis fig = make_subplots(specs=[[{"secondary_y": True}]]) # Add traces fig.add_trace( go.Scatter(x=[1, 2, 3], y=[40, 50, 60], name... Add solution -
Python 2022-01-29 09:26:37
k-means
import tkinter as tk from tkinter import filedialog import pandas as pd from pandas import DataFrame import matplotlib.pyplot as plt from sklearn.cluster import KMeans from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg root= tk.Tk() canvas1... Add solution -
Python 2022-01-26 00:25:53
3d plots in python
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x =[1,2,3,4,5,6,7,8,9,10] y =[5,6,2,3,13,4,1,2,4,8] z =[2,3,3,3,5,7,9,11,9,10] ax.scatter(x, y, z, c='r', marker='... Add solution