Python plt.plot getting unwanted lines
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
adrixas
il 12 Gen 2018
Risposto: SATTI SRIDHAR
il 17 Dic 2025 alle 15:31
Hi guys, I am trying to plot average usage by month. But somehow on the plot there are unwanted colorful line. The top brown line is correct, but other lines are unwanted. Maybe you know how to get rid of them, and why did they appear? I attached the image of the plot
1 Commento
SATTI SRIDHAR
il 17 Dic 2025 alle 15:31
import matplotlib.pyplot as plt
# ... your plotting code goes here ...
# e.g., plt.plot(wavelengths, spectra[0], ...)
# plt.plot(wavelengths, spectra[1], ...)
# ... and so on for all the stars
# Add the legend using the starnames array
plt.legend(starnames)
# ... potentially adjust legend location (optional) ...
# plt.legend(starnames, loc='upper left')
# Display the plot
plt.show()
Risposta accettata
Più risposte (2)
Steven Lord
il 12 Gen 2018
Can you show a small segment of your MATLAB code that calls Python and include a small data set with which you can see the unwanted colorful lines?
If you have your data and you want to bin it by month, consider using histogram with the 'DisplayStyle' option set to 'stairs'. I believe that will do what you want or something close to it.
1 Commento
SATTI SRIDHAR
il 17 Dic 2025 alle 15:31
import matplotlib.pyplot as plt
# ... your plotting code goes here ...
# e.g., plt.plot(wavelengths, spectra[0], ...)
# plt.plot(wavelengths, spectra[1], ...)
# ... and so on for all the stars
# Add the legend using the starnames array
plt.legend(starnames)
# ... potentially adjust legend location (optional) ...
# plt.legend(starnames, loc='upper left')
# Display the plot
plt.show()
0 Commenti
Vedere anche
Categorie
Scopri di più su Data Import and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!