What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-12 09:42:20
pandas plot heatmap
import matplotlib.pyplot as plt import seaborn as sns # optional: resize images from now on plt.rcParams["figure.figsize"] = (16, 12) # numeric_only_columns is a list of columns of the DataFrame # containing numerical data only # annot = True ... 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 -
Other 2021-11-10 02:49:13
_tkinter.tclerror: no display name and no $display environment variable
Matplotlib chooses Xwindows backend by default. You need to set matplotlib to not use the Xwindows backend. Add this code to the start of your script (before importing pyplot) and try again: import matplotlib matplotlib.use('Agg') Or add to .config/matp... Add solution -
Other 2021-11-09 06:17:20
matplotlib animate
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 -
Python 2021-11-08 20:34:16
if key in dict python time complexity
""" Time complexity of looking for a value in a hashable object is O(1). Dictionary keys are hashable. The code below is just for demonstration purposes, feel free to run it and see that the plot has no correlation with n. """... Add solution -
Python 2021-11-08 15:54:09
how to make a pairs plot with pandas
import pandas as pd import matplotlib.pyplot as plt %matplotlib inline from sklearn import datasets iris_dataset = datasets.load_iris() X = iris_dataset.data Y = iris_dataset.target iris_dataframe = pd.DataFrame(X, columns=iris_dataset.feature_names) ... Add solution -
Python 2021-11-08 08:29:14
python numpy find local minima
import numpy as np from scipy.signal import argrelextrema import matplotlib.pyplot as plt x = np.array([6, 3, 5, 2, 1, 4, 9, 7, 8]) y = np.array([2, 1, 3 ,5 ,3 ,9 ,8, 10, 7]) # sort the data in x and rearrange y accordingly sortId = np.argsort(x) x = x[... Add solution