Menu

Axes and Plot not lined up

Help
saultyevil
2015-11-16
2015-11-18
  • saultyevil

    saultyevil - 2015-11-16

    Hi, I've started a project in computational hydrodynamics. I'm using GDL to visualise the results I get. My supervisor handed me some IDL code which he has working on his machine with IDL. However, whenever I run the code on my machine the axes and the plot aren't lined up. I'm new to IDL/GDL and the code isn't commented that well so I'm really at a loss on where to start or how to fix it. I've tried changing values of !P.POSITION but that moves the plot with it and makes no difference. I've also tried changing some of the arguments to TVSCL but that resulted in an even bigger mess. Can anyone offer some help? I'll post an example image of my problem and a snippet of the code below.

    Thanks

    (http://i.imgur.com/GSpyCL4.png)

    ;;;;;;; DENSITY PLOT ;;;;;;;

    ;!P.POSITION = [left, bottom, right, top]
    !P.POSITION = [0.15,0.728,0.45, 0.94]

    plot,title="Density (log)",[0.0,npx],[0.0,npy],xticklen=-0.02,$ ;plot creates the axes
    ytitle='x1-units (zones)',xtitle='x2-units (zones)', $
    xstyle=2,ystyle=2, $
    yticks=4,$
    ytickname=yname, $
    xtickname=xname, $
    charsize=1.7

    px = !x.window * !d.x_vsize
    py = !y.window * !d.y_vsize
    swx = px(1)-px(0)
    swy = py(1)-py(0)

    if iplot eq 'ddy' then begin
    nm = 0
    ddn(,) = ddd(,,nm)
    endif

    if iplot eq 'ddz' then begin
    nm = 0
    ddn(,) = ddd(,nm,)
    endif

    tvscl,alog10(ddn),px(0),py(0),xsize = swx, ysize = swy ;plots the density image

     

    Last edit: saultyevil 2015-11-16
  • Alain C.

    Alain C. - 2015-11-17

    1/ which version version of GDL and plplot are you using ?
    GDL> print, !gdl
    (thanks to large refurbishing of graphical output during last winter,
    I suspect it might be better with current CVS version)

    2/ could you try to provide a small self consistant example ?
    (your image is smart, but we can try just with a DIST(npx, npy), isn't it ?

    Alain

    PS: for you information, DISPIM_BAR, whihch seems to be closely related to your exemple, works well in current GDL CVS

     
  • saultyevil

    saultyevil - 2015-11-18

    I'm using GDL 0.9.5. I've sorted it out my problem by defining the y argument in tvscl myself but it doesn't feel like a great fix. It looks like something is wrong with py, but px seems to work perfectly fine. So I basically did something like this,

    tvscl,alog10(ddn),px(0),22330,xsize = swx, ysize = swy

    Whilst the code works fine on Linux, when I use it on Mac OS X I get another problem. Basically, all the plots are lined up with the aes but they are now in the top right of the page (http://imgur.com/3RiNerT) and some aren't even on the page anymore. I've tried changing the page size using device and changing the position using !P.POSITION but it didn't help at all.

    I can provide the full code if you're curious.

     

    Last edit: saultyevil 2015-11-18
  • Michael Gregg

    Michael Gregg - 2017-10-16

    I am having a similar problem with a much simpler plot. I am making a scatter plot and wish to adjust the positions of the axes (the plot box boundaries) for output to a postscript file. In IDL, I can adjust these using !p.position=[x1,y1,x2,y2]. In GDL, this system parameter behaves differently, and, so far for me, rather unpredictably. In IDL, if you change just one of the limits in !p.position, say, x2, the right edge of the plot box moves while the other three edges stay fixed relative to the plot region, whether in a window on the screen or in a postscript output file. In GDL, adjusting x2 affects the placement of at least one and sometimes all the other plot edge positions in the output.
    I am using GDL 0.9.6, Oct 5 2017 build.

    Also, I would like to know how to change the font of the tick mark labels on the plot. In IDL, once I have specified a font in, say, an axis label (xtitle, for example), that font becomes the default for all further IDL text output. Not so in GDL, so how can I set the tickmark notation font in GDL? !p.font also seems to have no effect, beyond choosing -1 which give the machine generated fonts, and all other positive choices give the same font.

    Thanks for the help,

    Michael

     
    • giloo

      giloo - 2017-10-19

      Hi,
      Concerning the fonts, it is impossible at the moment to have TrueType or Hardware fonts for graphics, even if some of the DEVICE commands have been written. Mapping the IDL fonts to the plplot ones (plplot is the graphics library we use) is going to be very tricky.

      Concerning the !P.POSITION (and !P.REGION) problem, GDL, again because of some limitations of plplot, cannot easily manage both of them. I believe the behaviour of the 0.9.7 is OK, but if you could provide documented counter-examples (procedure+screen copy) it would help a lot.

       
  • Michael Gregg

    Michael Gregg - 2017-10-16

    Follow-up to my earlier query - it looks to me like GDL is using !p.position the way IDL uses !p.region. In IDL, !p.position specifies the position of the corners of the plot axes within the plot region, and the region is the entire plot including axes and tickmark labeling. GDL appears to be using the p.position elements to define the region rather than the position of the plot.

     

Log in to post a comment.