Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7081 > unrolled thread

Re: color-bar legend for the LisContourPlot

Started byJacopo Bertolotti <jacopo.bertolotti@gmail.com>
First post2011-12-10 12:36 +0000
Last post2011-12-11 08:55 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: color-bar legend for the LisContourPlot Jacopo Bertolotti <jacopo.bertolotti@gmail.com> - 2011-12-10 12:36 +0000
    Re: color-bar legend for the LisContourPlot Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-12-11 08:54 +0000
    Re: color-bar legend for the LisContourPlot Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-12-11 08:55 +0000

#7081 — Re: color-bar legend for the LisContourPlot

FromJacopo Bertolotti <jacopo.bertolotti@gmail.com>
Date2011-12-10 12:36 +0000
SubjectRe: color-bar legend for the LisContourPlot
Message-ID<jbvjp4$j20$1@smc.vnet.net>
I encountered a very similar problem and I am also searching for a 
solution that do not involve either ShowLegend or a third-part package.
The very best I came up with is something like
GraphicsRow[{ListContourPlot[RandomReal[30, {10, 10}],
    InterpolationOrder -> 3, ColorFunction -> "LakeColors"],
   MatrixPlot[Transpose@{Table[i, {i, 1, 30}]},
    FrameTicks -> {{None, {1, 10, 20, 30}}, {None, None}},
    ColorFunction -> "LakeColors"]}]
that is still far from ideal. Anyone with suggestions is welcomed.

Jacopo

On 12/09/2011 11:54 AM, Karamiarokhloo, M.P. (Mehdipasha) wrote:
> Dear All,
>
> I am using Mathematica 7 and have difficulties to plot the ListContourPlot
> of ocean data with a neat color bar (legend).
> For example if I have a temperature field range between {-2,30}, and I use
> the ColorFunction Rainbow,
> I cannot include a color-bar which has the same number of contours as the contourplot, and it does not show the related numbers for each color-shade.
> The ShowLegend function of Mathematica is very primitive.
> Has any body any suggestion?
>
> Thanks you.
> P.Karami
>
>

[toc] | [next] | [standalone]


#7114

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-12-11 08:54 +0000
Message-ID<jc1r3u$t2c$1@smc.vnet.net>
In reply to#7081
On Dec 10, 11:36 pm, Jacopo Bertolotti <jacopo.bertolo...@gmail.com>
wrote:
> I encountered a very similar problem and I am also searching for a
> solution that do not involve either ShowLegend or a third-part package.
> The very best I came up with is something like
> GraphicsRow[{ListContourPlot[RandomReal[30, {10, 10}],
>     InterpolationOrder -> 3, ColorFunction -> "LakeColors"],
>    MatrixPlot[Transpose@{Table[i, {i, 1, 30}]},
>     FrameTicks -> {{None, {1, 10, 20, 30}}, {None, None}},
>     ColorFunction -> "LakeColors"]}]
> that is still far from ideal. Anyone with suggestions is welcomed.
>
> Jacopo
>
> On 12/09/2011 11:54 AM, Karamiarokhloo, M.P. (Mehdipasha) wrote:
>
>
>
>
>
>
>
> > Dear All,
>
> > I am using Mathematica 7 and have difficulties to plot the ListContourP=
lot
> > of ocean data with a neat color bar (legend).
> > For example if I have a temperature field range between {-2,30}, and I =
use
> > the ColorFunction Rainbow,
> > I cannot include a color-bar which has the same number of contours as t=
he contourplot, and it does not show the related numbers for each color-sha=
de.
> > The ShowLegend function of Mathematica is very primitive.
> > Has any body any suggestion?
>
> > Thanks you.
> > P.Karami

AFAIK Graphics grid renders fixed grid sizes so is not a good
aesthetic choice if the plots you are combining have quite different
sizes. You can do this a number of ways but I think Labeled makes this
pretty easy once you make the plot and legend the same height (this is
optional but for me it looks better):

legendwidth=30;
plotheights=300;

Labeled[
 ListContourPlot[RandomReal[30, {10, 10}],
  InterpolationOrder -> 3,
  ImageSize -> plotheights+21,
  ImagePadding -> {{20, 1}, {20, 1}},
  ColorFunction -> "LakeColors"],
 MatrixPlot[Transpose@{Table[i, {i, 1, 30}]},
  AspectRatio -> plotheights/legendwidth,
  FrameTicks -> {{None, {1, 10, 20, 30}}, {None, None}},
  ImageSize -> {legendwidth+21, plotheights+2},
  ImagePadding -> {{1, 20}, {1, 1}},
  ColorFunction -> "LakeColors"],
 {{Right, Top}}]

To understand what I am doing with image padding and aspect ratio see
the current post "Precicely defining plot size ". You could control
the spacing between the plot and the legend by adjusting the image
padding on the plots.

Mike

[toc] | [prev] | [next] | [standalone]


#7117

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-12-11 08:55 +0000
Message-ID<jc1r6p$t33$1@smc.vnet.net>
In reply to#7081
On Dec 10, 11:36 pm, Jacopo Bertolotti <jacopo.bertolo...@gmail.com>
wrote:
> I encountered a very similar problem and I am also searching for a
> solution that do not involve either ShowLegend or a third-part package.
> The very best I came up with is something like
> GraphicsRow[{ListContourPlot[RandomReal[30, {10, 10}],
>     InterpolationOrder -> 3, ColorFunction -> "LakeColors"],
>    MatrixPlot[Transpose@{Table[i, {i, 1, 30}]},
>     FrameTicks -> {{None, {1, 10, 20, 30}}, {None, None}},
>     ColorFunction -> "LakeColors"]}]
> that is still far from ideal. Anyone with suggestions is welcomed.
>
> Jacopo
>
> On 12/09/2011 11:54 AM, Karamiarokhloo, M.P. (Mehdipasha) wrote:
>
>
>
>
>
>
>
> > Dear All,
>
> > I am using Mathematica 7 and have difficulties to plot the ListContourPlot
> > of ocean data with a neat color bar (legend).
> > For example if I have a temperature field range between {-2,30}, and I use
> > the ColorFunction Rainbow,
> > I cannot include a color-bar which has the same number of contours as the contourplot, and it does not show the related numbers for each color-shade.
> > The ShowLegend function of Mathematica is very primitive.
> > Has any body any suggestion?
>
> > Thanks you.
> > P.Karami

BTW in the post I sent a few minutes ago I noticed that the legend
colours aren't scaled right. I'm not sure why actually.
ColorFunctionScaling should scale between 0 and 1 that but it doesn't
appear to be doing that -- unless I am misunderstanding the usage. I
never use these plot types so I might be missing something but would
be interested if someone could explain. In any case if you rescale
yourself and switch ColorFunctionScaling off it seems to work:

MatrixPlot[Transpose@{Table[i, {i, 0, 30}]/30},
 AspectRatio -> plotheights/legendwidth,
 FrameTicks -> {{None, {1, 10, 20, 30}}, {None, None}},
 ImageSize -> {legendwidth + 21, plotheights + 2},
 PlotRangePadding -> 0, ImagePadding -> {{1, 20}, {1, 1}},
 ColorFunction -> "LakeColors", ColorFunctionScaling -> False]

Mike

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web