cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
JesperJohansen
Level IV

Changing the scales of a graph box

Hi

 

I am wirking on a custom graph. I want to draw the graph similar to this:

nw = New Window("Test",
Outline Box( "Outline",
gb = Graph Box(
FrameSize( 600, 300),
XName("X axis"),
YName("Y axis"),
X Scale( 0, 5*Pi() ),
Y Scale( -1, 1 )
)
)
);

gb << Set Graphics Script(Y Function(Sin(x), x));

 

Now I want to change the scales of the graph. I can drag to change the size and scale of the graph, but how do I change properties like "FrameSize" or "XName" by script, after I made the graph?

 

BR

Jesper

BR
Jesper
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Changing the scales of a graph box

I'm not sure why the gb<<framesize and gb<<xscale and gb<<Xname messages won't work (added to my list, thanks!), but these messages do:

gb<<setWidth(500); // or Height
gb<<getXaxis; // try this to see the syntax
gb<<setXaxis(min(1),max(3)); // uses same syntax
gb[textbox(1)]<<settext("Ralph"); // text box 1 is Y, 2 is X

The setXaxis message controls all of the axis parameters; here's what getXaxis returned:

{Scale( "Linear" ), Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 15.707963267949 ),
Interval( "Numeric" ), Inc( 5 ), Minor Ticks( 1 ), Label Row Nesting( 1 ),
Label Row(
    {Automatic Font Size( 0 ), Automatic Tick Marks( 0 ), Inside Ticks( 0 ),
    Label Orientation( "Horizontal" ), Major Grid Line Color( -14145495 ),
    Minor Grid Line Color( -15790320 ), Show Major Grid( 0 ), Show Major Labels( 1 ),
    Show Major Ticks( 1 ), Show Minor Grid( 0 ), Show Minor Labels( 0 ),
    Show Minor Ticks( 1 ), Tick Offset( 0 )}
)}

(Using JMP 13, might be fewer options in earlier versions.)

 

Craige

View solution in original post

9 REPLIES 9
Craige_Hales
Super User

Re: Changing the scales of a graph box

I'm not sure why the gb<<framesize and gb<<xscale and gb<<Xname messages won't work (added to my list, thanks!), but these messages do:

gb<<setWidth(500); // or Height
gb<<getXaxis; // try this to see the syntax
gb<<setXaxis(min(1),max(3)); // uses same syntax
gb[textbox(1)]<<settext("Ralph"); // text box 1 is Y, 2 is X

The setXaxis message controls all of the axis parameters; here's what getXaxis returned:

{Scale( "Linear" ), Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 15.707963267949 ),
Interval( "Numeric" ), Inc( 5 ), Minor Ticks( 1 ), Label Row Nesting( 1 ),
Label Row(
    {Automatic Font Size( 0 ), Automatic Tick Marks( 0 ), Inside Ticks( 0 ),
    Label Orientation( "Horizontal" ), Major Grid Line Color( -14145495 ),
    Minor Grid Line Color( -15790320 ), Show Major Grid( 0 ), Show Major Labels( 1 ),
    Show Major Ticks( 1 ), Show Minor Grid( 0 ), Show Minor Labels( 0 ),
    Show Minor Ticks( 1 ), Tick Offset( 0 )}
)}

(Using JMP 13, might be fewer options in earlier versions.)

 

Craige
JesperJohansen
Level IV

Re: Changing the scales of a graph box

Thank you. Just what I was looking for :)
BR
Jesper
hogi
Level XIII

Re: Changing the scales of a graph box

an alternative approach: Send a message to the AxisBox 

gb[Axisbox( 1 )] << {Min( 1 ), Max( 3 )};

... which, unfortunately, is not available if the axis is not available due to SuppressAxes.
And I didn't want to show, change and hide again the axis. 

So, thanks a lot for this EasterEgg :)

 

btw.
seems that curly brackets are necessary to get the second argument executed as well:

 

gb<<setXaxis({min(1),max(3)});
hogi
Level XIII

Re: Changing the scales of a graph box

Ouch!


So even 

gb<<setXaxis({min(1),max(3)});

talks to the AxisBox.
After re-enabling the SuppressAxes, the rescale command didn't wok anymore :(
--> no AxisBox, no rescale possible.

hogi
Level XIII

Re: Changing the scales of a graph box


@hogi wrote:

And I didn't want to showchange and hide again the axis.


Now, with the feeling that I do not have another choice  ...
is there even a possibility to do so?

 

Like FrameSize, SuppressAxes doesn't seem to work if sent to a Graph Box - although it seems to be a valid message to be sent to a Graph Box:

hogi_1-1675001398829.png                     hogi_0-1675001342958.png

 

 

 

hogi
Level XIII

Re: Changing the scales of a graph box



@Craige_Hales wrote:

I'm not sure why the gb<<framesize and gb<<xscale and gb<<Xname messages won't work (added to my list, thanks!),


 

ah, maybe because they are no messages, but "named property arguments" - which have to be used as argument, and cannot be used as message:

hogi_0-1768243063559.png

 

Add-On questions:

  • Is Graph Box a Display Box - where can I find it in the Scripting Index?

hogi_2-1768243222004.png

 

  • How can I activate the documentation for Set X Axis?

hogi_1-1768243154870.png

Craige_Hales
Super User

Re: Changing the scales of a graph box

GraphBox() is a function that returns a more complicated nest of display boxes than the other xxxBox() functions.

Craige_Hales_0-1768278399627.png

 

 

 

 

Craige
hogi
Level XIII

Re: Changing the scales of a graph box

I mean, in analogy to a Graph Builder Box, which is generated by Graph Builder().
hogi_2-1768287692294.png


The recipient of << set X Axis()is a  "Custom Box"?

hogi_1-1768287679155.png

 

In the  Scripting Index, Custom Box doesn't know a message << set X Axis():

hogi_3-1768287948932.png

 

OwnerBox?
hogi_0-1768286939145.png

Craige_Hales
Super User

Re: Changing the scales of a graph box

Yes, I saw that too. The OwnerBox is a very thin wrapper box used to attach a scriptable interface (with commands in addition to the scripting a box normally has.) My quick test did not convince me that the custombox was that scriptable interface. Probably it just forwards some commands to the appropriate grandchild box.

Craige

Recommended Articles