Re: SmoothHistogram and Legends
- To: mathgroup at smc.vnet.net
- Subject: [mg126828] Re: SmoothHistogram and Legends
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Mon, 11 Jun 2012 00:01:05 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <699541.29032.1339226519200.JavaMail.root@m06>
You can readily determine the default color scheme.
p = Plot[Evaluate[
Table[a*x, {a, 15}]],
{x, 0, 1}]
The colors are
colors = Cases[p, Hue[__], Infinity]
{Hue[0.67, 0.6, 0.6], Hue[0.906068, 0.6, 0.6], Hue[0.142136, 0.6, 0.6],
Hue[0.378204, 0.6, 0.6], Hue[0.614272, 0.6, 0.6], Hue[0.85034, 0.6, 0.6],
Hue[0.0864079, 0.6, 0.6], Hue[0.322476, 0.6, 0.6], Hue[0.558544, 0.6, 0.6],
Hue[0.794612, 0.6, 0.6], Hue[0.0306798, 0.6, 0.6], Hue[0.266748, 0.6, 0.6],
Hue[0.502816, 0.6, 0.6], Hue[0.738884, 0.6, 0.6], Hue[0.974952, 0.6, 0.6]}
Note that the green and blue components are constant at 0.6 and only
the red component varies. Plotting the red component:
n = 1; ListPlot[
c = Cases[colors,
Hue[r_, 0.6, 0.6] :> {n++, r},
Infinity]]
These are lines of constant slope
f[{lb_, ub_}] := FindFit[
Select[c, lb <= #[[1]] <= ub &],
a*x + b, {a, b}, x]
f /@ {{1, 2}, {3, 6}, {7, 10}, {11, 15}}
{{a -> 0.236068, b -> 0.433932}, {a -> 0.236068,
b -> -0.566068}, {a -> 0.236068, b -> -1.56607}, {a -> 0.236068,
b -> -2.56607}}
red[n_?NumericQ] := Module[
{y = 0.236068 n + 0.433932},
y - Floor[y]];
Plot[red[x], {x, 0, 15.2},
Epilog -> {Red, AbsolutePointSize[3],
Point[c]}]
The colors are then
color[n_Integer] := Hue[red[n], 0.6, 0.6]
Bob Hanlon
On Sun, Jun 10, 2012 at 2:16 AM, djmpark <djmpark at comcast.net> wrote:
> There is probably a way to do this in regular Mathematica that someone will
> show you. But since you indicate that you have searched and not found a
> working method I will make a custom graphic using the Presentations
> Application. I do the first example in SmoothHistogram/Scope/Data.
>
> << Presentations`
>
> ShowLegend[
> Draw2D[
> {MapThread[(SmoothHistogram[
> RandomVariate[NormalDistribution[#1, 1/#1], 10^4],
> PlotStyle -> #2,
> Filling -> Axis,
> FillingStyle -> Opacity[0.5, Blend[{#2, White}, 0.5]]] //
> DrawGraphics) &,
> {Range[4], {Blue, Magenta, Brown, Green}}]},
> AspectRatio -> 1,
> PlotRange -> {0, 1.6},
> Axes -> True],
>
> {{{Blue, "Curve 1"},
> {Magenta, "Curve 2"},
> {Brown, "Curve 3"},
> {Green, "Curve 4"}},
> LegendPosition -> {-1.1, 0.6},
> LegendSize -> {0.7, 0.3},
> LegendTextOffset -> {-0.6, 0},
> LegendSpacing -> 0.6},
> BaseStyle -> {FontSize -> 12, FontWeight -> "Bold"}]
>
> I used the ShowLegend statement, MapThread to construct each curve, and the
> DrawGraphics command to pick off the graphics primitives. It would be nice
> if WRI made available the canonical list of colors and fills they use with
> multiple curves.
>
>
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/index.html
>
>
>
> From: dangoogle at warp-7.com [mailto:dangoogle at warp-7.com]
>
>
> I am trying to put a legend on a SmoothHistogram that I generate
> (Mathematica 8), using an array of 6 data sets. I can not find a single
> method for making a legend on a SmoothHistogram. All of the methods that
> work with other charts and graphics don't seem to work with a
> SmoothHistogram. Has anyone accomplished this?
>
>
--
Bob Hanlon