Arrange a list of plots and multiple lines of text using ggarrange or grid.arrange

Advertisements I would like to arrange a list of plots and several lines of text in one graph using grid.arrange or ggarrange. Following is what I have tried, but I prefer to use grid.arrange(grobs = plot_list, ncol = 2) combined with text, instead of typing plots in the list one by one, if possible. (Refer… Read More Arrange a list of plots and multiple lines of text using ggarrange or grid.arrange

How to change the legend string for different subplots?

Advertisements I would like to add a legend to every subplot as shown below each legend is theta_(1/2)=5, theta_(1/2)= 10, theta_(1/2)=15,…,theta_(1/2)=60. How can I change the number for each legend? Q = [16,32,64,128,256,512,1024]; VEC_Beam_5 = [113.2659 69.7204 51.8739 34.5033 21.6538 10.9459 5.9488]; % Coverage area of Theta = 5 VEC_Beam_10 = [117.5491 76.1452 53.3016 38.3105… Read More How to change the legend string for different subplots?

How to remove all y-axis tick labels and markers except for '0' in a matplotlib subplot?

Advertisements The code: import matplotlib.pyplot as plt from matplotlib.dates import DateFormatter fig, axs = plt.subplots(2, sharex = True, figsize=(9,6),dpi=500, gridspec_kw={‘height_ratios’: [3, 1]}) axs[0].set_title("Smoothed Kalman Point Estimate Fit to " + symbol) axs[0].plot(dates, price_series, c=’black’, linestyle = ‘-‘, linewidth = 2) axs[0].plot(dates, kf_point_est, c=’yellow’, linestyle = ‘-‘, linewidth = 1) axs[0].xaxis.set_major_formatter(DateFormatter("%y")) axs[0].margins(x=0) axs[1].set_title("Slope") axs[1].plot(dates, pos_slope, color=’g’)… Read More How to remove all y-axis tick labels and markers except for '0' in a matplotlib subplot?

Make a parabola steeper at both sides while keeping both ends

Advertisements I’m having a parabola with both axes being from 0 to 1 as follows: The parabola is created and normalized with the following code: import matplotlib.pyplot as plt import numpy as np # normalize array def min_max_scale_array(arr): arr = np.array(arr) return (arr – arr.min())/(arr.max()-arr.min()) x = np.linspace(-50,50,100) y = x**2 x = min_max_scale_array(x) y… Read More Make a parabola steeper at both sides while keeping both ends

Move the bottom of a curve without changing both ends

Advertisements I’m having a curve as follows: The curve is generated with the following code: import matplotlib.pyplot as plt import numpy as np # normalize array def min_max_scale_array(arr): arr = np.array(arr) return (arr – arr.min())/(arr.max()-arr.min()) x = np.linspace(-50,48,100) y = x**2 + 2*x + 2 x = min_max_scale_array(x) y = min_max_scale_array(y) fig, ax = plt.subplots()… Read More Move the bottom of a curve without changing both ends

wrong time and resolution axis when plotting time series (secs instead of min)

Advertisements I want to plot a DataFrame as a time series import matplotlib.pyplot as plt plt.plot(df[‘time’],df[‘Power’]) or df2 = df.set_index(‘time’) df2.Power.plot() which both show all 3531 y values correctly but wrong x axis time labels, like 25 seconds instead of 25 minutes. timestamps are not completely regular and have ms decimals 0 2022-05-16 19:59:25.690 1… Read More wrong time and resolution axis when plotting time series (secs instead of min)