matplotlib

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

How to plot multiple dataframes with different lenghts into one plot

How to plot multiple dataframes with different lenghts into one plot Question: the question I have a lot of dataframes (approx. 300) that I would like to plot into one line chart. The issue is – they all have different number of values (lengths). How to normalise the dataframes, so they can be plotted on …

Total answers: 4

Incorrect value and positioning of proportions

Incorrect value and positioning of proportions Question: Why do some percentages not add up to 100% and how do I correct the positioning of the proportion value for the last bar? The data is accessible from https://www.kaggle.com/datasets/mfaisalqureshi/hr-analytics-and-job-prediction?select=HR_comma_sep.csv. Thanks! # Group the data by ‘work_accident’, ‘salary’, and ‘left’ columns and calculate the count grouped_data = df1.groupby([‘work_accident’, …

Total answers: 1

Matplotlib with Numba to try and accelerate code

Matplotlib with Numba to try and accelerate code Question: How could I use numba for the following code to try and accelerate it? When I add @njit before func1 several error returns? Or would there be another way to optimise/accelerate the code to reduce the overall process time as depeding on the number of iterations …

Total answers: 1

Matplotlib – Line plot not appearing

Matplotlib – Line plot not appearing Question: I am trying to plot a chart with multiple plots like line, scatter etc., The line plot Im trying to plot is not showing up on the chart. I want a line plot like this: fig, ax = plt.subplots(figsize=(20, 6)) plt.plot(result, color=’red’) plt.show() I want this to show …

Total answers: 2

How can I display error bars an a datetime.datetime axis?

How can I display error bars an a datetime.datetime axis? Question: I’m trying to make a plot with error bars along the time axis, ideally with adjustable upper/lower error limits. I’ve been using the datetime.datetime datatype to do this, which has been reliable until I’ve tried to implement error bars with matplotlib.pyplot.errorbar(). import matplotlib.pyplot as …

Total answers: 2

plt.show() results in an empty plot figure

plt.show() results in an empty plot figure Question: plt.show() isn’t working in Matplotlib Python My Code: # Python program to show pyplot module import matplotlib.pyplot as plt from matplotlib.figure import Figure # Creating a new figure with width = 5 inches # and height = 4 inches fig = plt.figure(figsize =(5, 4)) # Creating a …

Total answers: 1

How to format datetimes in Power BI for a matplotlib visualization

How to format datetimes in Power BI for a matplotlib visualization Question: I have a problem with the Power BI dataset that I could not resolve in the past month so In the below picture you can see my steps which are numbered. In the first step, you can see my data source which is …

Total answers: 1

Separate axis in two parts, give each a label and put it in a box

Separate axis in two parts, give each a label and put it in a box Question: My current approach does not automatically center the ‘HIGH’ and ‘LOW’ descriptions. I would like them automatically centered at 25% and 75% of corresponding axis. Another phrasing: I want the ‘HIGH’ label exactly centered inside its surrounding box. Maybe …

Total answers: 1

How to format the timeseries axis of a matplotlib plot like a pandas plot

How to format the timeseries axis of a matplotlib plot like a pandas plot Question: I’ve created following graph with pd.Series([1]*month_limits.size, month_limits).plot(ax=ax) How do I recreate same x ticks labels with just matplotlib? I mean years and month not overriding each other Best I got is having years and months at the same time, but …

Total answers: 1