Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label objects not found

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?

enter image description here

like image 627
JDGD Avatar asked May 01 '14 22:05

JDGD


People also ask

How do I label data using label objects for deep learning?

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.

What is an object that is not visible on label?

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.

How do I use the labeled objects tab?

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.

How do I label an image with a specific 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.


1 Answers

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.

like image 133
CT Zhu Avatar answered Oct 16 '22 02:10

CT Zhu