Setup a graph using matplotlib which is working properly (see image below), but when I try to add a legend I get the following error: UserWarning: No labeled objects found. Use label='...' kwarg on indivial plots.
Here's the code I'm using to define the lines that I want in the legend and draw the legend:
#Moving average labels
smaLabel1 = str(SMA1)+'d SMA'
smaLabel2 = str(SMA2)+'d SMA'
smaLabel3 = str(SMA3)+'d SMA'
#Add SMAs to chart
ax1.plot(ind, avg1, '#5998ff', label=smaLabel1, linewidth=1)
ax1.plot(ind, avg2, '#ffbb82', label=smaLabel2, linewidth=1)
ax1.plot(ind, avg3, '#d689c4', label=smaLabel3, linewidth=1)
""" End SMA additions """
#Add legend
plt.legend()
I've checked the smaLabel
variables, and all hold the correct strings. Anyone know why the labels aren't registering?
The Label Objects for Deep Learning pane can be used to quickly and accurately label data. The Label Objects for Deep Learning button is found in the Classification Tools drop-down menu, in the Image Classification group on the Imagery tab.
Visible: if the checkbox is not selected, the object neither appears on the print preview nor on the printed label. The object is treated as if it does not exist. Text box object is a container for textual content on a label.
The Labeled Objects tab is located in the bottom section of the pane and manages the training samples you have collected for each class. Collect representative sites, or training samples, for each class in the image. A training sample has location information (polygon) and an associated class.
For instances when you don't want to draw a boundary around an object, you can use the Label Image button to label the entire image with the selected class, irrespective of the spatial aspect of the object. The Labeled Objects tab is located in the bottom section of the pane and manages the training samples you have collected for each class.
You must have plot the candle plots and the volume before plotting the SMA. The candle plot doesn't have any labeled object, when you call the plt.legend()
, it tries to plot a label for every plot on the current axes. Therefore, you get this UserWarning: No labeled objects found. Use label='...' kwarg on indivial plots.
To solve it, I hope it is clear at this point, simply requires you to plot the SMA's very first, before the candle plot, and call the legend()
right after that before any other plots being generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With