# Color in Multiple Subplots Plotly Chart

I would like to have a multiple subplots to compare before and after workout progress. As you can see in the attached image, they are all in different colors and I would like to have the same color of before and after workout in each plot. Anyone knows how to do that? This is what… Read More Color in Multiple Subplots Plotly Chart

# How to have a figure legend and a subplot legend in python?

I would like to plot some data in subplots and I would like to have a legend for the overall figure but also a legend for one of the subplots, where the labels of the subplot should not appear in the figure label. Here is an example: import matplotlib.pyplot as plt import numpy as np… Read More How to have a figure legend and a subplot legend in python?

# How to change the legend string for different subplots?

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 23.0815… Read More How to change the legend string for different subplots?

# why do 2 histograms overlap in matplotlib?

In this python script is an attempt to create two histogram in one figure but the second histogram overlaps the first one from random import randrange import matplotlib.pyplot as plt fig = plt.figure(figsize=(50,50)) ids = [ str(randrange(10000, 99999)) for i in range(1000)] ids2 = [ str(randrange(10000, 99999)) for i in range(1000)] def fun1(): ax =… Read More why do 2 histograms overlap in matplotlib?

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

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’) axs[1].plot(dates,… 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

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

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() ax.plot(x,… Read More Move the bottom of a curve without changing both ends

# Plot on secondary yaxis not appearing in Python

I am currently trying to plot two sets of data on the same figure, sharing the same x axis but with distinct y axes. However, when I plot this, only the data from axis y1 shows up. how can i ensure that the data from both axes is present. My code is below: #!/usr/local/bin/python3 import… Read More Plot on secondary yaxis not appearing in Python

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

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 2022-05-16… Read More wrong time and resolution axis when plotting time series (secs instead of min)

# In skimage, how to get cmap from one generated image, and use it in another image?

If I plot two images with cmap="gray": on Im1 (left), the tile with value 0.1 is light grey On Im2 (right), the tiles are all defined with value 0.1, but there are all black So how do I obtain the same light grey on Im2 ? import matplotlib.pyplot as plt import numpy as np Im1… Read More In skimage, how to get cmap from one generated image, and use it in another image?