Prev: Gnuplot from array
Next: Looking for some advice on string passing and dealing with hardcodedconstants
From: Charles on 12 May 2010 06:17 "glen herrmannsfeldt" <gah(a)ugcs.caltech.edu> wrote in message news:hsdelk$b2e$1(a)speranza.aioe.org... > Charles <C.Sanders(a)deletethis.bom.gov.au> wrote: > (snip on plot scaling) > >> You have to compute a suitable interval, something like >> (untested, somewhat obsfuscated): [snip] >> The 1.0e-5 is to cope with rounding errors in the division so that (for >> example) >> 6/3.0 does not become 1.9999.... and get truncated to 1 instead of 2; >> almost any positive value less than about 0.15 can be used. Floor is used >> instead of integer division so negative numbers work correctly. If your >> compiler does not have flooor and ceiling, you can use other intrinsics >> such as nint(x-0.5) or nint(x-0.5+1.0e-20) instead of floor(x). > > I believe ones I used to know subtracted a small amount such that if > the range was just slightly over it wouldn't need to go up to the next > scale factor. The 1.9999 shouldn't be so bad, but consider the case > where the tentative scale factor is 2.00001. The last point will > still be within the width of the line, so that isn't so bad. > If you go up to the next, 4 or 5, you waste most of the plot area. Nothing is perfect, and it is very hard to get all the corner cases right without a lot of code. Also, if you are using (say) about 10 tick marks, then unnecessarily jumping up one tick mark only wastes about 10% of the plot area. The waste is greater if you are aiming to only have 2 or three tick marks. >> Alternatively, and a lot clearer and longer, you can use the log10 >> of range/nstep to scale range/nstep to 1.0..10.0, and then use a chain >> of if statements to use 1.0 for (say) 1.0..1.5; 2.0 for 1.5..3.0; 5.0 for >> 3.0..7.0; and 10.0 for 7.0..10.0, all re-scaled using the same power >> of 10 that was used for the initial scaling. > > Or a DO loop over an array of choices. Yes, a good alternative to a chain of if statements > >> That is effectively what the >> code above does, except that it multiplies the log by 3 and used >> mod to pick the appropriate value from 1, 2 and 5, and divides by >> three to get the power of 10, resulting in much shorter, but >> obsfuscated, code. > > It seems that it might be a little off, as 2 and 5 aren't so > close to 10.**(1./3.) and 10.**(2./3.) Yes, the code I gave will not always get the best tick mark spacing. To two decimal places, it will give 1.0 when the calculated spacing is between 1.00 and 1.47 instead of the better 1.0 to 1.41, 2.0 between 1.47 and 3.16 instead of the ideal 1.41 to 3.16, 5.0 between 3.16 and 6.81 instead of 3.16 and 7.07, and 10.0 between 6.81 and 10.00 instead of 7.07 and 10.00. However, it is close enough for most cases - within about 4%. > [snip] > -- glen
From: ndl_91 on 14 May 2010 09:01 On 12 mai, 04:29, ivan martin <i.mar...(a)invalid.com> wrote: > Greetings all, > > following dpb's advice from my previous question: 'calling a subroutine with a "string constant"': > I have the need for it for when I run into some strange results data, that I can relatively quickly > plot it. > .... > With regards, > Ivan Hello Ivan. I'm not sure I've understood your main expectation but if you're just interested in plotting data you should use a simple external program such as gnuplot. gnuplot can do quite the same as the DISLIN library. Having a simple gnuplot script will allow you to draw your curves. Contact me if you want some more details. NL
From: GaryScott on 14 May 2010 10:28 On May 14, 9:22 am, ivan martin <i.mar...(a)invalid.com> wrote: > On Fri, 14 May 2010 06:01:23 -0700 (PDT), ndl_91 <nicolas.lardj...(a)gmail.com> wrote: > >On 12 mai, 04:29, ivan martin <i.mar...(a)invalid.com> wrote: > >> Greetings all, > > >> following dpb's advice from my previous question: 'calling a subroutine with a "string constant"': > >> I have the need for it for when I run into some strange results data, that I can relatively quickly > >> plot it. > > >... > >> With regards, > >> Ivan > > >Hello Ivan. > >I'm not sure I've understood your main expectation but if you're just > >interested in plotting data you should use a simple external program > >such as gnuplot. gnuplot can do quite the same as the DISLIN library. > >Having a simple gnuplot script will allow you to draw your curves. > >Contact me if you want some more details. > >NL > > Hi Nicolas, > > I've seen gnuplot a couple of times, and indeed it is a very nice library (little buggy perhaps ... > autoscaling with multiple plots causes one plot to dissapear). > > In this case my main objection to it, is that I've never managed to get it working in a way, in > which I operate DISLIN, that I can use it from "inside" my program. > I have no problems with writing for example, a data file, or a .gnu file. What I don't understand is > how I can call gnuplot from my fortran program (with a system command), in a way that it draws me my > plot, and afterwards leaves me on dos/cmd prompt instead of gnuplot prompt. > > Something like: > - instead of: > c:\> gnuplot > gnuplot> load 'my_file.gnu' > ... gives out plot > ... I close the graph, and I'm back on > gnuplot> > > - I'm looking for a way to do: > c:\> gnuplot ... something ... 'my_file.gnu' > ... gives out plot > ... I close the graph, and I'm back on > c:\> > > Is there such a way of operating gnuplot (I need a way to draw my plots and stay inside my fortran > program) ? > > -- > Ivan- Hide quoted text - > > - Show quoted text - For free I assume...of course GINO and Winteracter can do all that and much more, even motion and 3D
From: ndl_91 on 14 May 2010 12:58 On 14 mai, 16:22, ivan martin <i.mar...(a)invalid.com> wrote: > On Fri, 14 May 2010 06:01:23 -0700 (PDT), ndl_91 <nicolas.lardj...(a)gmail.com> wrote: > >On 12 mai, 04:29, ivan martin <i.mar...(a)invalid.com> wrote: > >> Greetings all, > > >> following dpb's advice from my previous question: 'calling a subroutine with a "string constant"': > >> I have the need for it for when I run into some strange results data, that I can relatively quickly > >> plot it. > > >... > >> With regards, > >> Ivan > > >Hello Ivan. > >I'm not sure I've understood your main expectation but if you're just > >interested in plotting data you should use a simple external program > >such as gnuplot. gnuplot can do quite the same as the DISLIN library. > >Having a simple gnuplot script will allow you to draw your curves. > >Contact me if you want some more details. > >NL > > Hi Nicolas, > > I've seen gnuplot a couple of times, and indeed it is a very nice library (little buggy perhaps ... > autoscaling with multiple plots causes one plot to dissapear). > > In this case my main objection to it, is that I've never managed to get it working in a way, in > which I operate DISLIN, that I can use it from "inside" my program. > I have no problems with writing for example, a data file, or a .gnu file. What I don't understand is > how I can call gnuplot from my fortran program (with a system command), in a way that it draws me my > plot, and afterwards leaves me on dos/cmd prompt instead of gnuplot prompt. > > Something like: > - instead of: > c:\> gnuplot > gnuplot> load 'my_file.gnu' > ... gives out plot > ... I close the graph, and I'm back on > gnuplot> > > - I'm looking for a way to do: > c:\> gnuplot ... something ... 'my_file.gnu' > ... gives out plot > ... I close the graph, and I'm back on > c:\> > > Is there such a way of operating gnuplot (I need a way to draw my plots and stay inside my fortran > program) ? > > -- > Ivan I don't know about msdos but under UNIX like system (or cygwin for windows ;) ) you can either: A./ Open a FIFOfile (see man mkfifo) before launching your executable and send any gnuplot command to it from inside your code. You can either send data directly through this pipe or use a temporary external file. Both ways work fine. B./ Or, from your Fortran code make a system call to open gnuplot and do quite the same as A. I use either methods, mainly to monitor my application or do some animations, they are really simple to implement. NL
First
|
Prev
|
Pages: 1 2 Prev: Gnuplot from array Next: Looking for some advice on string passing and dealing with hardcodedconstants |