[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plot range in Object Graphics



David Fanning wrote:

> I really think this is a simple problem of not scaling
> either the data or the axes properly.
> ...
> You have to go get the *actual* values of your axes and
> scale the data to those, or you will get exactly the problems
> you describe.

While I agree that scaling the axes and plot correctly is a pain, and that not scaling
properly can produce this result, in this case it looks to me like it is a problem with
version 5.0.  The code below, when used in IDL5.0 exhibits the problem, whereas in
IDL5.3 it looks fine.

************
 thisPlot = Obj_New("IDLgrPLOT", findgen(10), sin(findgen(10)),xrange=[0,8.5],
Color=[255,255,255])
 thisPlot->GetProperty, XRange=xrange, YRange=yrange

 xAxis1 = Obj_New("IDLgrAxis", 0, Color=[255,255,255],Range=xrange, Location=[10, 0
,0], $
    /Exact, name='xaxis1')
 yAxis1 = Obj_New("IDLgrAxis", 1, Color=[255,255,255],Range=yrange, Location=[0,10,0],
$
    /Exact, name='yaxis1')
 yAxis2 = Obj_New("IDLgrAxis", 1, Color=[255,255,255],Range=yrange, Location=[1,10,0],
$
    /Exact, ame='yaxis2')

 xAxis1->GetProperty, CRange=xrange
 yAxis1->GetProperty, CRange=yrange

 xs = Normalize(xrange)
 ys = Normalize(yrange)

 thisPlot->SetProperty, XCoord_Conv=xs, YCoord_Conv=ys
 xAxis1->SetProperty, XCoord_Conv=xs
 yAxis1->SetProperty, YCoord_Conv=ys
 yAxis2->SetProperty, YCoord_Conv=ys

 thisModel = Obj_New('IDLgrModel')
 thisModel->Add, xAxis1
 thisModel->Add, yAxis1
 thisModel->Add, yAxis2
 thisModel->Add, thisPlot

 thisView = Obj_New('IDLgrView', Viewplane_Rect=[-.2, -.2, 1.3, 1.3], Location=[0,0],
Color=[0,0,0])
 thisView->Add, thisModel
 thisWindow->Draw, thisView

 xAxis1->GetProperty, CRange=xrange
 yAxis1->GetProperty, CRange=yrange
 anotherPlot = Obj_New("IDLgrPLOT", findgen(20)-5.2, sin(findgen(20)),xrange=xrange, $
    yrange=yrange, Color=[255,0,0], XCoord_Conv=xs, YCoord_Conv=ys)
 thisModel->Add, anotherPlot
 thisWindow->Draw, thisView
*************


> P.S. Please don't implement the Polygon idea.

Don't worry. That's why I spend so much time reading this newsgroup.


> It's just to grim to imagine and is in the worst tradition of just getting
> the damn thing to work. :-(

Unfortunately, as a physicist who needs to do my own -quick- visualizations while
learning IDL at the same time, I have sometimes had to write code that would make a
true software engineer shriek in horror in order to meet a deadline. This is, I think,
sometimes a necessary evil. A sin, on the other hand, would be never bothering to learn
the proper technique, or worse yet, writing improper code that will fall into the hands
of other people.

Have you ever used duct-tape to patch a radiator hose so that you can get to work?


Brad