Message Boards Message Boards

1
|
1867 Views
|
3 Replies
|
5 Total Likes
View groups...
Share
Share this post:

How to make a reversed rescaled axis in ListContourPlot?

Hi, All!

POSTED BY: Vladimir Ivanov
3 Replies

It appears that ScalingFunctions is flipping the sign of the y-values.

lp = ListContourPlot[tmap,ImageSize->200,FrameTicks->Automatic,ScalingFunctions->{Identity,"Reverse"},DataRange->{{1,10},{1,100}}] ;

PlotRange /. AbsoluteOptions[lp]

So, this will show the contours:

ListContourPlot[tmap, ImageSize -> 200, FrameTicks -> Automatic, 
 ScalingFunctions -> {Identity, "Reverse"}, 
 DataRange -> {{1, 10}, {1, 100}},
 PlotRange -> {{1., 10.}, {-100, -1}}
 ]

But, the contours have been messed up. I think contacting Tech Support may be your next step.

For a work-around, mapping your data as the first step:

ListContourPlot[Reverse@tmap, DataRange -> {{1, 10}, {1, 100}},  ImageSize -> 200]

may be what you are after.

POSTED BY: W. Craig Carter

Here's a workaround:

Show[
 ListContourPlot[tmap, ImageSize -> 200, FrameTicks -> Automatic, 
   DataRange -> {{1, 10}, {1, 100}}] /.
  (* reverse (negate) y coordinates *)
  GraphicsComplex[p_, g___] :> 
   GraphicsComplex[Transpose[{#1, -#2} & @@ Transpose[p]], g]
 , PlotRange -> All
 , FrameTicks -> {
   (* reverse (negate) left/right ticks *)
   {Charting`ScaledTicks["Reverse", {-#1 &, -#1 &}, "Nice", 
     WorkingPrecision -> 15.954589770191003`, RotateLabel -> 0],
    Charting`ScaledFrameTicks[{-#1 &, -#1 &}]},
   (* keep top/bottom ticks *)
   {Automatic, Automatic}}]

As Craig said, it's probably a bug. Also as he indicated, scaling/transformations are achieved by transforming the data and then mapping the ticks to the original values. The above relies on all the coordinates in the graphics to be in the first argument of GraphicsComplex[], which is the case here. You could also manage the whole process of transforming the data and ticks yourself:

Show[
 ListContourPlot[
   tmap, ImageSize -> 200
   ] /. GraphicsComplex[p_, g___] :>
   GraphicsComplex[
    Transpose[{Rescale[#1, MinMax[#1], {1, 10}], 
        Rescale[-#2, MinMax[-#2], {-100, -1}]} & @@ Transpose[p]],
    g]
 , PlotRange -> All
 , FrameTicks -> {
   {Charting`ScaledTicks["Reverse", {-#1 &, -#1 &}, "Nice", 
     WorkingPrecision -> 15.954589770191003`, RotateLabel -> 0],
    Charting`ScaledFrameTicks[{-#1 &, -#1 &}]},
   {Automatic, Automatic}}]

P.S. The following fixes the ticks in Craig's solution the way I interpret what is desired:

ListContourPlot[Reverse@tmap, DataRange -> {{1, 10}, {1, 100}}, 
 ImageSize -> 200,
 FrameTicks -> {
   {Charting`ScaledTicks[{101 - #1 &, 101 - #1 &}],
    Charting`ScaledFrameTicks[{101 - #1 &, 101 - #1 &}]},
   {Automatic, Automatic}}]
POSTED BY: Michael Rogers

Thank you for your answers!

POSTED BY: Vladimir Ivanov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract