Jump to content

XY-graph: programmatically add point "labels"


machyaer

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

Link to comment

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.

Link to comment

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.

Link to comment

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.

Link to comment
.... 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

Link to comment

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
Link to comment

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.

Link to comment
  • 4 months later...

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.

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.