Python Forum
Inserting a variable name into xlabel - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Inserting a variable name into xlabel (/thread-19242.html)



Inserting a variable name into xlabel - myersluke - Jun-19-2019

Hi, first post here.

I am trying to streamline a lot of data processing by using a class of objects called "image". I define each image as "image1 = image(...), image2 = ..." and so on.

class image(self, path):
...
image1 = image('pathway')
I am looking to plot data that can be distinguished from each image, but I can't seem to figure out how to insert a variable value that isn't a number. Would it look something close to this:

plt.xlabel("pixels (x), %" % self)
where self is the image name (ie image1, image2...)?

The errors that keep popping up only relate to the type of value it should be:
"must be real number, not image"

If I can't get a word in there, I can always just add an assigned number to the class values or whatever. But I would prefer the actual name for this.

Thank you!