What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-03 23:07:07
matplotlib secondary x axis
import matplotlib.pyplot as plt import numpy as np import datetime import matplotlib.dates as mdates from matplotlib.transforms import Transform from matplotlib.ticker import ( AutoLocator, AutoMinorLocator) fig, ax = plt.subplots(constrained_layout=... Add solution -
Python 2021-10-24 10:07:08
change xlabel python
import matplotlib.pyplot as plt fig, ax = plt.subplots() # We need to draw the canvas, otherwise the labels won't be positioned and # won't have values yet. fig.canvas.draw() labels = [item.get_text() for item in ax.get_xticklabels()] labels[1] = 'Tes... Add solution -
Python 2021-10-20 14:20:10
python convert ylabel to currency
import numpy as np import matplotlib.pyplot as plt import matplotlib.ticker as ticker # Fixing random state for reproducibility np.random.seed(19680801) fig, ax = plt.subplots() ax.plot(100*np.random.rand(20)) formatter = ticker.FormatStrFormatter('$%1... Add solution -
Other 2021-10-20 08:32:13
sklearn random forest feature importance
import pandas as pd forest_importances = pd.Series(importances, index=feature_names) fig, ax = plt.subplots() forest_importances.plot.bar(yerr=std, ax=ax) ax.set_title("Feature importances using MDI") ax.set_ylabel("Mean decrease in impuri... Add solution -
Python 2021-10-19 12:50:14
seaborn create horizontal bar graph
import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(style="whitegrid") # Initialize the matplotlib figure f, ax = plt.subplots(figsize=(6, 15)) # Load the example car crash dataset crashes = sns.load_dataset("car_crashes&q... Add solution -
Other 2021-10-18 18:40:12
matplotlib pie chart label order
import matplotlib.pyplot as plt import pandas as pd #corresponding color-label pairs colors = ['#99f3bd', '#fbaccc', '#a8df65', '#ff7b54'] labels = ["Yes", "Sometimes", "Most of the times", "No"] #... Add solution -
Python 2021-10-17 13:54:07
matplotlib get padding from bbox
import matplotlib matplotlib.rc('text',usetex=True) import matplotlib.pyplot as plt from matplotlib.patches import Rectangle import numpy as np text = '\\begin{tabular}{|c|c|}\\hline1&2\\\\\\hline3&4\\\\\\hline\\end{tabular}' fig, ax = plt.subpl... Add solution