LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting additional vertical lines in XY Graph

Solved!
Go to solution

Hello there

 

I would like to ask for your help… I have not found a solution for my problem and every one I try is a more complicated one… (witch may not be seen in the vi, I cleaned it up a bit)… and it has come to my mind, that maybe there is a simple way of solving my problem, but I have no idea it exists (I am a self-learner in Lab View).

 

The idea is simple, really… I plotted an example course on the XY graph and now I would like to plot additional vertical lines at specified X points… In the example vi I inserted 4, but the problem is that sometimes it may by 4 and sometimes 500 and so… and in every X point there will be, I would like to draw a vertical line…

 

I found ways to draw single lines in specific X coordinates points, as you may see in the vi, but the only idea that comes to my mind when trying to make more vertical lines is to bundle more points in the array, but due to that there is no fix number of X points in which the vertical lines should be (4, 5000, it changes), I don’t think it is a good option and I would like to ask for your help before I go that way.

I had no problem with drawing a horizontal line when I knew the Y coordinates in a similar problem, but the vertical line… I got to a point in which I am humbly asking for your help.

 

I attached my vi and the example course.

Thank you in advance for your help and time.

Download All
0 Kudos
Message 1 of 7
(4,479 Views)
Solution
Accepted by Rockfor

Hello Rockfor,

 

I read thourgh your description of the problem and have some ideas you could try out!

I highly suggest you to play around with the settings of the XY Graph. Which could suit you is the setting called "Bar Plots". This setting creates vertical lines to each and every point shown in the plot applied to. 
So the idea is the following:
You have an array of your X points. Now make an array of the same dimension (Y array) of the constant number for example 200 (just above your maximum of 100). Make a plot out of these two, so now you have for example points of:
(1.01101, 100) ; (2.2000, 100) ; (3.2111, 100) ... and so on.

If you enable the setting in Bar Plots seen in the picture you will get vertical lines. Now the idea is to disable Autoscaling on the Y axis, and set it to lets say 100. So when you plot your two plots, you will not see the actual points, just the lines you wanted to see.
XY Graph.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I hope I could point you to the right direction and you can complete your application successfully! Please reply if you could apply the solution or have further questions!

Best regards,

Peter

 

 

 

 

 

 

 

Peter L.
National Instruments Hungary
Applications Engineer
0 Kudos
Message 2 of 7
(4,439 Views)

Dear Peter

 

Thank you for the reply. I actually had a Y array of points to plot with the X  points (one of my earlier experiments) but the problem was, when I had those points plotted, all I got was a horizontal line, the graph plotted and connected the points. Your suggestion to use the Bar Plots option was awesome, I got the lines… and the horizontal one will not be a problem, as you said.

 

Only question – is there a way to alter the vertical’s lines width? Changing the Line Width option (the same menu you posted in the reply) only results in the change of the connected horizontal line. I would guess that the proper option is in the Create -> Property Node -> etc. option of the XY Graph.

 

Thank you again for the reply.

0 Kudos
Message 3 of 7
(4,432 Views)

You can explore how to create cursors, that option can help you with your requirement.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 4 of 7
(4,429 Views)

Dear Rockfor,

 

I am afraid that, as of LabVIEW 2012 version, there are no settings/properties for the Bar Plot line width to alter. You could try and look around working with cursors, but if what you wrote in the specifications (number of lines could be 5000...) then that is not an option I think. 

If you want to change the width of a bar plot then you must create a workaround. The XY Graph works as if you were holding a pen always down and go from point to point. So you could create a plot where, when you want to plot the number point (50,110) and (90,75) for example, you go from (0,0) to (50,0) then (50,110) then (50,0) then (90,0) then (90, 75) and then again back to (90,0).. so the idea is to "return the pen". So you go up, then down, then to the next point, up and down again...

The logic for this could be complicated and time consuming, but is doable. 

Best regards, 

Peter

Peter L.
National Instruments Hungary
Applications Engineer
0 Kudos
Message 5 of 7
(4,421 Views)

Dear Peter

 

Yes, that’s one of the solutions I thought of, but realizing it will be time-consuming, I decided to ask here for help. Your answer was very helpful, thank you and well... that width of the line will have to do.

 

Thank you again!

0 Kudos
Message 6 of 7
(4,405 Views)

One way of setting your vertical lines' (bars') width which I used on a project was a bit off-the-wall, but it worked. It appears that the only three settings you have for bar width are: 1 pixel, most of the available width (i.e., if your bar is centered at x=8, then you fill from 7.7 to 8.3 or so, I can't remember exactly what percentage of the width), and filling the whole available width (i.e., from 7.5 to 8.5). So you have to use a bar width property value of 2 or 3.

 

What I did was use a different X-axis for my bar chart and calculate it by multiplying the original X-axis by a constant (say, 5, or whatever makes your bars a reasonable width for you). Multiply the values for your bar placements by 5 ("new bar x value" = 5 * "desired x value on old graph"), also. Overlay the new graph on the original one (lining up the start and end of both graphs, then make the new X-axis [and actually everything except your bars] transparent). At this point, you may have to add a small constant to your bar placement (for instance, "new bar x value" = 5 * "desired x value on old graph" + 1.3) just to make things line up exactly right. The advantage to this is that once you have set things up, you can hardwire in that formula for converting your real X numbers to make your vertical bars even when you change X scales on the original graph.

 

Cameron

 

Now (within the next 30 minutes) somebody will come along with a much simpler or less Rube Goldbergian way to do what you want, or NI will even have a beautiful method in LV2013 since I took all the time to work this one out, but at least it does work. Remember, TIMTOWTDI.

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 7 of 7
(4,378 Views)