Python plt.plot getting unwanted lines
4 views (last 30 days)
Show older comments
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 Comment
SATTI SRIDHAR
2 minutes ago
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()
Accepted Answer
More Answers (2)
Steven Lord
on 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 Comment
SATTI SRIDHAR
2 minutes ago
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 Comments
See Also
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!