[yt-users] Star Projections

John Wise jwise at physics.gatech.edu
Wed Nov 28 14:01:21 PST 2012


Hi Munier,

I've run into this problem before.  You can set the color of any values 
above or below the colorbar range (or NaNs) to any color you want, using 
the set_bad, set_over, and set_under matplotlib commands.

http://matplotlib.org/api/colors_api.html?highlight=set_bad#matplotlib.colors.Colormap.set_bad

Here's an example.  You have to manually set the colormap first, though.

pc = PlotCollection(pf)
p = pc.add_projection('Density',0)
p.set_cmap('algae')
p.cmap.set_under('k')  # black
p.cmap.set_bad('k')    # black
p.cmap.set_over('w')   # white

you can also use html hex colors or RGB tuples for your colors.

Let us know if this works for you!
Cheers,
John

On 11/28/2012 12:29 PM, Munier Azzam Salem wrote:
> Hi yt gurus,
>
>        I've been making projections of star_density from enzo output
> files and they seem to be working out fine. However, wherever particles
> do not exist the background remains white instead of following my chosen
> colormap. Is there a way to paint these areas to follow the colormap?
>
>         thanks!
>             Munier
>
> I've attached an image of what gets plotted, and the relevant bits of my
> script are:
>
> *from yt.mods import **
> *
> *
> *fName = "DD0006/test_sim_0006"*
> *var   = "star_density"*
> *axis  = 0*
> *
> *
> *pf = load(fName)*
> *pf.h*
> *
> *
> *pc = PlotCollection(pf)*
> *p = pc.add_projection(var,axis)*
> *#p.modify["particles"](1.0)*
> *
> *
> *radius = .02;*
> *
> *
> *pc.set_xlim(.5-radius,.5+radius)*
> *pc.set_ylim(.5-radius,.5+radius)*
> *
> *
> *pc.save(fName)*
>
>
> --
> Munier A. Salem // 845.489.6450
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>

-- 
John Wise
Assistant Professor of Physics
Center for Relativistic Astrophysics, Georgia Tech



More information about the yt-users mailing list