Python plt.plot getting unwanted lines
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
adrixas
am 12 Jan. 2018
Beantwortet: SATTI SRIDHAR
am 17 Dez. 2025 um 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 Kommentar
SATTI SRIDHAR
am 17 Dez. 2025 um 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()
Akzeptierte Antwort
Weitere Antworten (2)
Steven Lord
am 12 Jan. 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 Kommentar
SATTI SRIDHAR
am 17 Dez. 2025 um 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 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!