MathGroup Archive 1994

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Scale Transformations

	Jean Peccoud writes:

> Does anybody know a package to modify the scales of 2D graphics. I would
> like to apply with other functions a transformation similar to the Log
> transformation in a LogLog or semiLog plot. My particular interest is in
> gaussian plots.

I have been using the following hack for a while, and it works fine. 
The nice thing about it is that you can build a Graphics object however you 
like (with Plot, ListPlot, Graphics, whatever), and only at the end play with 
the axes. Changing the axis scale of a graph is usually a snap on 
even the most pathetic piece of software, but not with Mma. 
I find it useful because often I want to see the same graphs on 
Linear and Log scales, and my graphs contain many functions, data points,
and error bars. So I find this little hack much more useful than most of 
Graphics.m (WRI, are you there?). You can use it to warp the axes with 
any transormation. I am too lazy to have it adjust the labels and the ticks, 
so there is plenty of room for improvement. Hope this helps,


				Matteo Carandini	
				Center for Neural Science	
				New York University		
				6 Washington Place, #809	
				New York NY 10003	
				(212) 998 7898 (voice)
				(212) 995 4011 (fax)
				matteo at

	I think that Mma is a GREAT environment to do science (and education),
so I am surprised at how bad it is at generating simple, 
publication-quality graphs. For example, in my last posting I showed how 
making a nice Bode plot is a headache. I received many letters of people
asking to post a solution. I don't have a solution! ask WRI.

(* ********************* super hack to warp the axes *********************** *)
(* ********************* (does not deserve a package) <********************** *)

Options[ WarpShow ]:= { XWarp->Identity, YWarp->Identity }

WarpShow[ graphics_Graphics, opts___ ]:= 
	{ 	xwarp = XWarp /. {opts} /. Options[WarpShow], 
		ywarp = YWarp /. {opts} /. Options[WarpShow] },
		( # /. { {x_?NumberQ,y_?NumberQ}->N[{xwarp[x],ywarp[y]}] } )&,
	    FilterOptions[ Graphics, opts ]

(* example:

mygraph = Plot[ x^2/(0.25+x^2), {x,0,1} ]
WarpShow[ mygraph ]
WarpShow[ mygraph, XWarp->Log ]
WarpShow[ mygraph, XWarp->(Log[2,#]&), YWarp->(Log[10,#]&) ]

bizarrewarp[ x_ ]:= Exp[ x^2 ]
WarpShow[ mygraph, XWarp->bizarrewarp, PlotRange->All ]
(* *************************************************************** *)

  • Prev by Date: re: Re: Global styles definitions
  • Next by Date: re: Coloring 2DPlot with different colors
  • Previous by thread: Scale Transformations
  • Next by thread: Stanford math archive's computer will be in hospital