Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

RE: Smoother shading in DensityPlot?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32747] RE: [mg32694] Smoother shading in DensityPlot?
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Fri, 8 Feb 2002 03:49:19 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: Gennady [mailto:stupakov at SLAC.Stanford.EDU]
To: mathgroup at smc.vnet.net
> Sent: Wednesday, February 06, 2002 9:42 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg32747] [mg32694] Smoother shading in DensityPlot?
> 
> 
> Hello,
> 
> I am doing density plots and find that Mathematica uses rather limited
> number of the shading levels in DensityPlot. For example, execute the
> following
> command
> DensityPlot[.1 Sin[x] + 0.5, {x, 0, \[Pi]/2}, {y, 0, 1}, 
> PlotPoints -> 50,
>     Mesh -> False, ColorFunctionScaling -> False];
> and you will see about 7 gray stripes instead of smooth 
> transition. I guess,
> Mathematica uses 64 gray levels in this kind of graphs.
> 
> My question: is it possing to increase the number of descreet 
> gray levels
> and to make the plot above to look smooth, as a photograph?
> 
> Thank you.
> Gennady.
> 
> 
> 
You used the option ColorFunctionScaling -> False; if you are happy with

DensityPlot[.1 Sin[x] + 0.5, {x, 0, \[Pi]/2}, {y, 0, 1}, PlotPoints -> 50, 
    Mesh -> False];

just use it (and stop reading).

If I have a close look at
 
DensityPlot[x, {x, 0, 1}, {y, 0, 1}, PlotPoints -> 50, Mesh -> False, 
    Frame -> False, Background -> GrayLevel[0.5]];

on my monitor, I can only discern about 30 - 33 gray levels (instead of 50);
especially there are some neigboring strips of same shade, which should not
be. (There is an obvious optical illusion involved with the picture, cover
the vicinity of two strips to compare them.)

We may look how many gray levels Mathematica produces:

level = c[]; DensityPlot[x, {x, 0, 1}, {y, 0, 1}, PlotPoints -> 50, 
  ColorFunction -> ((level = c[level, {#, GrayLevel[#]}]; GrayLevel[#]) &), 
  Mesh -> False, Frame -> False, Background -> GrayLevel[0.5]];
{flevels, graylevels} = Transpose[List @@ Flatten[level]];

Union[flevels]
Length[%]
50

(we see 50 function levels)

Union[graylevels]

(we see 50 gray level specifications)

Now look at Postscript:

DensityPlot[x, {x, 0, 1}, {y, 0, 1}, PlotPoints -> 50, 
    ColorFunction -> GrayLevel, Mesh -> False, Frame -> False, 
    Background -> GrayLevel[0.5], 
    DisplayFunction -> (Display["grayleveltest.dat", #] &)];

!! "grayleveltest.dat"

(therein we find the byte pattern for the gray levels, it's this:)

bytestring = 
 
"00050A0F141A1F24292F34393E43494E53585E63686D72787D82878D92979CA1A7ACB1B6B\
CC1C6CBD0D6DBE0E5EBF0F5FAFF";

StringLength[bytestring]
100

We convert it to numbers:

chs = ReadList[StringToStream[bytestring], Character];
ToExpression@StringJoin["16^^", #] & /@ StringJoin @@@ Partition[chs, 2]

{0, 5, 10, 15, 20, 26, 31, 36, 41, 47, 52, 57, 62, 67, 73, 78, 83, 88, 94, \
99, 104, 109, 114, 120, 125, 130, 135, 141, 146, 151, 156, 161, 167, 172, \
177, 182, 188, 193, 198, 203, 208, 214, 219, 224, 229, 235, 240, 245, 250, \
255}

This is roughly the same as

Table[Round[i 255/49], {i, 0, 49}]

{0, 5, 10, 16, 21, 26, 31, 36, 42, 47, 52, 57, 62, 68, 73, 78, 83, 88, 94, \
99, 104, 109, 114, 120, 125, 130, 135, 141, 146, 151, 156, 161, 167, 172, \
177, 182, 187, 193, 198, 203, 208, 213, 219, 224, 229, 234, 239, 245, 250, \
255}

So I conclude the problem is not with Mathematica. It might be with the
Postscript interpreter, and I would have liked to look at the file with
Ghostview.

So there rests the possibility, that some coarseness is introduced by
Mathematica's postscript interpreter. It can however be with our graphics
cards or drivers.

--
Hartmut Wolf



  • Prev by Date: Re: constraint
  • Next by Date: Mathmatica animations embedded in Power Point Presentations
  • Previous by thread: Re: Smoother shading in DensityPlot?
  • Next by thread: The prime factors of n.