What do you want to save?
Add Code snippet
New code examples
-
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-29 07:42:13
Image to grayscale using python
import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg def rgb2gray(rgb): return np.dot(rgb[...,:3], [0.299, 0.587, 0.144]) img = mpimg.imread('img.png') gray = rgb2gray(img) plt.imshow(gray, cmap='gray') plt.savefig(... Add solution -
Python 2022-01-26 08:25:56
Create donut chart using matplotlib
# library import matplotlib.pyplot as plt # create data size_of_groups=[12,11,3,30] # Create a pieplot plt.pie(size_of_groups) # add a circle at the center to transform it in a donut chart my_circle=plt.Circle( (0,0), 0.7, color='white') p=plt.gcf() p.... Add solution -
Python 2022-01-26 07:30:09
poisson disc python
import numpy as np import matplotlib.pyplot as plt # Choose up to k points around each reference point as candidates for a new # sample point k = 30 # Minimum distance between samples r = 1.7 width, height = 60, 45 # Cell side length a = r/np.sqrt(2) ... 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 -
Python 2022-01-24 21:25:02
seaborn heatmap spearman correlation coefficient
# credit to Stack Overflow user in the source link import pandas as pd import seaborn as sns import matplotlib.pyplot as plt A = [...] # insert here your list of values for A B = [...] # insert here your list of values for B df = pd.DataFrame({'A': A, ... 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