Jump to content
machyaer

XY-graph: programmatically add point "labels"

Recommended Posts

Hello to everybody,

 

I'm wondering to find a solution to this problem...

 

I have an xy-graph and I would like to insert programmatically some text label connected to certain x-y coordinates of the plot itself.

 

Does somebody know if it is possible? ... and have an idea on how to implement such behaviour?

 

Thanks

Max

Share this post


Link to post
Share on other sites

There is built in functionally to do this but I find it lacking. Instead I use the graph method to translate the point coordinate to a pixel coordinate, then use the picture primitives to draw text, arrows, or other features, and place the resulting picture in one of the graph's plot image layers.

Share this post


Link to post
Share on other sites

You could use a slide with text labels and put it above the scale. Make the slide transparent so that you only see the scale. Now you have to transfer the scale setting from the plot scale to the slide scale and define the appropriate label. But if the scales of the plot are not fixed you need to change the size of the slide using splitter bars because the plot area changes if the plot scales display different numbers. Its quite difficult to implement but the additional label is not in the plot area as in mje much simpler solution.

Share this post


Link to post
Share on other sites

I believe the built in function mje was referring to is the graph cursors.  Right click the graph go to Visible Items and choose cursors.  Then you can make a cursor that will snap to existing points.  There are several examples if you search the example finder.  One is called Programatically Control Cursors but I have seen some other's that work better and can and and and point out the maximum value of a graph.

 

Again if these functions don't meet your needs you can just draw a picture and put it on top of the plot using the property nodes of the graph it self.

Share this post


Link to post
Share on other sites

thanks for the replies, I'm not sure that all the solution proposed should solve the problem... for this reason I attached an example image...

 

I will try unicorn solution that perhaps should function...

 

Max

post-787-0-27998100-1385128712.png

Share this post


Link to post
Share on other sites
.... you can just draw a picture and put it on top of the plot using the property nodes of the graph it self.

 

Thanks hooovahh but my problem is that I don't know the final position of each label nor the amount of labels I have to insert...

 

Max

Here's a brief example how to draw your own images on plots. The VI simply tracks the x-location of the mouse and draws a circle around the corresponding data point. You could use whatever logic you want (closest Cartesian point, tracking multiple plots, whatever) and draw any info you'd like, but this should get you started if the built in functionality doesn't suffice.

interesting solution, I suppose usable also in LV2012...

 

I will make a try...

 

Max

Share this post


Link to post
Share on other sites

The picture functions are nearly as old as time itself, I'm not sure how far back the plot image properties go back, but at least as far as 2009. I've saved the VI for 2012:

 

Mouse Tracking LV12.vi

Share this post


Link to post
Share on other sites

I worked on something much like this before, but never wound up fully finishing or using it.  Here is code that is meant to be called in an event structure for a "mouse up" event in a Waveform Graph.  It expects the control reference, the coordinates (both returned by the event) and a name to put on the annotation.  See if this does what you want.

 

post-19157-0-99028400-1385145728_thumb.p

 

  • Like 1

Share this post


Link to post
Share on other sites

For having text labels on your plotted graph you shouldn't take my solution. It's for textlabels in the x- or y-axes scale where you don't want to have a programmatic restriction in the number of labels.

 

For your task cursors or annotations are the best solution as the others suggest.

Share this post


Link to post
Share on other sites

I tried the mje solution and found a good compromise.

 

Than I've tryed to mix mje and jordan solutions... and here we are!!! This is the right solution.

 

:worshippy:  :thumbup1:
 

 

Thank!

 

Max

Share this post


Link to post
Share on other sites
Than I've tryed to mix mje and jordan solutions... and here we are!!! This is the right solution.

Did you mean to attach something to that post?

Share this post


Link to post
Share on other sites
Yes, I would also be interested to see how you combined the two approaches.

 

Especially as he marked his answer as Best Answer" to his own question.

 

Now. Where are all my posts :D.

  • Like 2

Share this post


Link to post
Share on other sites

ShaunR  :beer_mug: 

 

you are true, it was not the best way to check both the solutions received... So I changed to the one I used mostly...

 

Attached the portion interested...

 

Thanks again

Max

post-787-0-11356800-1385395900_thumb.png

Edited by machyaer

Share this post


Link to post
Share on other sites

I could probably use this solution on a current project.  Unfortunately,  I have no idea what functions the green icons represent.  Is there any way to get an image posted that has the function labels turned on?

Share this post


Link to post
Share on other sites

Green icons are OpenG toolkit functions.  You can install OpenG with VIPM.

 

 

Here's a brief example how to draw your own images on plots. The VI simply tracks the x-location of the mouse and draws a circle around the corresponding data point. You could use whatever logic you want (closest Cartesian point, tracking multiple plots, whatever) and draw any info you'd like, but this should get you started if the built in functionality doesn't suffice.

 

attachicon.gifMouse Tracking.png

attachicon.gifMouse Tracking LV13.vi

 

 

 

I just used annotations yesterday to mark things on a graph, and reacquainted myself with their limitations.  I think I’ll try your picture solution.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.