Skip to main content
12-Amethyst
July 4, 2011
Solved

Plotting a Grid or a Structure on a Graph

  • July 4, 2011
  • 5 replies
  • 11104 views

Attached is what I am settling on as the best way to create a grid or to plot a structure on a graph,

Any suggestions?

Thanks,

Wayne

Best answer by RichardJ

I think you are making it somewhat more complicated than it needs to be, You don't need all those NaNs.

5 replies

24-Ruby III
July 5, 2011

Wayne,

Thank you for this program!

24-Ruby IV
July 5, 2011

Wayne Reid wrote:

Any suggestions?

Thanks,

Wayne

It is a subroutine?!

A subroutine must not be depended on an ORIGIN value!

I think so!

1-Visitor
July 5, 2011

Wayne,

I have a new idea, but it's still a working progress

I am planning on using my Lines function.

Mike

RichardJ19-TanzaniteAnswer
19-Tanzanite
July 5, 2011

I think you are making it somewhat more complicated than it needs to be, You don't need all those NaNs.

wayne12-AmethystAuthor
12-Amethyst
July 5, 2011

Richard,
Thanks, that is much cleaner

Needed all then NaN's because the the results were not always the same without being redundant. I assume that I will not have the same problems with what you sent.

Generally, plotting A to B to NaN works for a simple gird, but not always for other structures. (that's why I said "assume" above)

Plotting A to B to A to NaN seems to always work, but it's sort of vulgar.

Again,

Thanks

19-Tanzanite
July 5, 2011

Yes, this will always work.

Perhaps a more detailed explanation (i.e. more detailed than no explanation at all ) will help clarify.

Take a polyline with N segments, so N+1 x coordinates and N+1 y coordinates. This can be plotted as an N+1 vector of the x coordinates vs an N+1 vector of y coordinates (obviously!). If we have multiple polylines then we can create a matrix of x coordinates and a matrix of y coordinates. Each column will be plotted as an independent polyline. If we like (and I do, so I always do it this way) we can combine the x and y coordinates into one matrix by using complex numbers of the form x+iy, and then create the x and y matrices on the fly when plotting by using the Re and Im functions. For a grid the lines only have one segment, so the matrix only has two rows. If we have lines with different numbers of segments then the unused positions in the matrix can be filled with NaNs: see the slightly modified worksheet.

19-Tanzanite
July 5, 2011

Here's how I'd do it.

Alan

wayne12-AmethystAuthor
12-Amethyst
July 5, 2011

Thanks Alan,

That's clever.

I mentioned grids because I thought that would get the most interest.

However, I am actually looking for the best method to plot a structure that, in general, does not correspond to a grid.

By the way, I think you are guilty of suggesting that I use NaN's last September or so (Richard was supposedly at a "convention" at the time)

Thanks,

Wayne

19-Tanzanite
July 6, 2011

Wayne Reid wrote:

Thanks Alan,

That's clever.

I mentioned grids because I thought that would get the most interest.

However, I am actually looking for the best method to plot a structure that, in general, does not correspond to a grid.

Oh well, another good idea bites the dust!

By the way, I think you are guilty of suggesting that I use NaN's last September or so (Richard was supposedly at a "convention" at the time)

Thanks,

Wayne

Yep, that would be me - nothing wrong with a few good NaNs! (Are you intimating that Richard might be something other than an honest, trustworthy, solid citizen?)

Alan