matplotlib

Only the first row of annotations displayed on seaborn heatmap

Only the first row of annotations displayed on seaborn heatmap Question: As it’s usually advised, I have managed to reduce my problem to a minimal reproducible example: import numpy as np import seaborn as sns import matplotlib.pyplot as plt matrix = np.array([[0.1234, 1.4567, 0.7890, 0.1234], [0.9876, 0, 0.5432, 0.6789], [0.1111, 0.2222, 0, 0.3333], [0.4444, 0.5555, …

Total answers: 5

How to extract xvalues and yvalues from a kdeplot

How to extract xvalues and yvalues from a kdeplot Question: Given that I have a seaborn.kdeplot I want to extract the x and y points. Based on similar questions I have tried the following: points = sns.kdeplot(targets, shade=True, label=’train’).get_lines()[0].get_data() x = points[0] y = points[1] But I’m getting the error Traceback (most recent call last): …

Total answers: 1

positioning ipywidget slider to the side of a figure

positioning ipywidget slider to the side of a figure Question: I am new to ipywidget. I am using an ipywidget slider to change images in a matplotlib figure. However I would like to change the position of the slider to put it next to the image. I’ve already looked for similar questions but none satisfies …

Total answers: 1

Plot with low resolution curves

Plot with low resolution curves Question: My problem requirement is to redraw a graph with curves at low resolution. As shown below: Is there a way to do it with matplotlib library or any image processing solution? Currently matplotlib is producing lines with very high smoothness as shown below: Here is the drawing function I …

Total answers: 1

How to plot grouped bars overlaid with lines

How to plot grouped bars overlaid with lines Question: I am trying to create a chart below created in excel based on the table below using matplotlib.. Category %_total_dist_1 event_rate_%_1 %_total_dist_2 event_rate_%_2 00 (-inf, 0.25) 5.7 36.5 5.8 10 01 [0.25, 4.75) 7 11.2 7 11 02 [4.75, 6.75) 10.5 5 10.5 4.8 03 [6.75, …

Total answers: 2

MatplotLib line behind bar plot

MatplotLib line behind bar plot Question: I have the function detailed below. It works perfectly well to produce the bar and line plot for the comparisons I am after but the line is behind the bars. Any ideas on what I am doing wrong? The lineInput, barInput and xlabel variables are a pd.DataFrame rows where …

Total answers: 1

Plot datetime object as continuous variable

Plot datetime object as continuous variable Question: Need a hand with some plotting on Seaborn (sns). I’m using Python 3.11.4 on Jupyter Notebooks v6.5.4 via the Anaconda Navigator v.23.7.2, on MacOS. I have a data frame of which a portion is shown below. Behaviour was pre-converted to numeric values using pandas.DataFrame.replace but the issue comes …

Total answers: 1

custom legend function for matplotlib chart

custom legend function for matplotlib chart Question: Right now when I have dual y-axis and I want to have one legend box for both of my labels I do the following: fig, ax = plt.subplots(1,2) ax0=ax[0].twinx() line1=ax[0].plot([1, 2, 3], [4, 5, 6], ‘b’, lw=1, label=’Line 1′) line2=ax0.plot([1, 2, 3], [6, 5, 4], ‘r’, lw=1, label=’Line …

Total answers: 1

How to put value over bars when creating many barplots with a loop

How to put value over bars when creating many barplots with a loop Question: How can I put the value over the bars when creating many plots with a loop. The code I am using years = [twenty,twentyone,twentytwo,twentythree] for year in years: plt.ylim(0, 60) ax = sns.barplot(data=year, errorbar=None) ax.set_xticklabels(ax.get_xticklabels(), rotation=45, horizontalalignment=’right’) for i in ax.containers: …

Total answers: 1

Modifying the Patch in the legend leaving alone the Patch in the scatter plot

Modifying the Patch in the legend leaving alone the Patch in the scatter plot Question: I can change the opacity of an item in the legend of a scatter plot import matplotlib.pyplot as plt # note the alpha value vvvvvvvvvv plt.scatter(range(10), range(10), alpha=0.15, label=’Mount Resegone’) plt.scatter(range(10), [0]*10, alpha=0.15, label=’Rimini Beach’) plt.gca().get_legend_handles_labels()[0][0].set_alpha(1.0) plt.legend() plt.show() but doing …

Total answers: 1