Is there a way to set the background color for projection plots? I'd like to set it to be black instead of white, which I assume is the default. Thanks, Andrew E. -- Graduate Student Columbia University Department of Astronomy
Hi Andrew, On Wed, May 28, 2014 at 1:12 PM, Andrew James Emerick < emerick@astro.columbia.edu> wrote:
Is there a way to set the background color for projection plots? I'd like to set it to be black instead of white, which I assume is the default.
That's right, following matplotlib's defaults. There are two options to create a plot with a black background color. The first is to pass the 'facecolor' keyword argument down to matplotlib when calling the save function. Unfortunately since the foreground is black by default, you'll also have to adjust the colors of all of the axes, tick marks, axes text, colorbars, etc to be white. Here is an example notebook that does this: http://nbviewer.ipython.org/gist/ngoldbaum/7367380cbe6683159da5 Another option would be to adjust the matplotlib defaults in your matplotlibrc (http://matplotlib.org/1.3.1/users/customizing.html) so that figures have a black background by default. I have to say that I kind of like the way the black background looks and could definitely see it being useful in some situations. I don't think it would be very hard to add a "set_black_theme" function that does more or less what my notebook does. That would probably be a nice afternoon hack for someone that wanted to familiarize themselves with yt's plotting code. Hope that's helpful, Nathan
Thanks, Andrew E. -- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
A third rather dumb solution that I use is to add a tinny-tiny number to the field I’m projecting. I assume you are getting the white where the field is zero? If you are using a color bar with black as the color for the lowest value (like 'gray’), this will give you black where the field you are projecting is zero (or rather tinny-tiny). Christine On May 28, 2014, at 2:51 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Andrew,
On Wed, May 28, 2014 at 1:12 PM, Andrew James Emerick <emerick@astro.columbia.edu> wrote: Is there a way to set the background color for projection plots? I'd like to set it to be black instead of white, which I assume is the default.
That's right, following matplotlib's defaults.
There are two options to create a plot with a black background color. The first is to pass the 'facecolor' keyword argument down to matplotlib when calling the save function. Unfortunately since the foreground is black by default, you'll also have to adjust the colors of all of the axes, tick marks, axes text, colorbars, etc to be white. Here is an example notebook that does this: http://nbviewer.ipython.org/gist/ngoldbaum/7367380cbe6683159da5
Another option would be to adjust the matplotlib defaults in your matplotlibrc (http://matplotlib.org/1.3.1/users/customizing.html) so that figures have a black background by default.
I have to say that I kind of like the way the black background looks and could definitely see it being useful in some situations. I don't think it would be very hard to add a "set_black_theme" function that does more or less what my notebook does. That would probably be a nice afternoon hack for someone that wanted to familiarize themselves with yt's plotting code.
Hope that's helpful,
Nathan
Thanks, Andrew E. -- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Nathan & Christine, Thanks for the fixes. The 'dumb' solution is the one I was planning on doing if there wasn't a more attractive option, but I wanted to see if there was a built-in way to do this without changing the field values. Nathan: I do like your solution, and I do like the way the white on black looks in the plot. Its probably not universally useful, but I can imagine using it in some cases. Is there any way to do the matplotlib level commands though such that its just the background within the plot itself that changes (keeping the plot borders white). Basically doing what Christine suggested without editing the fields. Andrew E. On Wed, May 28, 2014 at 5:00 PM, Christine Simpson < csimpson@astro.columbia.edu> wrote:
A third rather dumb solution that I use is to add a tinny-tiny number to the field I’m projecting. I assume you are getting the white where the field is zero? If you are using a color bar with black as the color for the lowest value (like 'gray’), this will give you black where the field you are projecting is zero (or rather tinny-tiny).
Christine
On May 28, 2014, at 2:51 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Andrew,
On Wed, May 28, 2014 at 1:12 PM, Andrew James Emerick < emerick@astro.columbia.edu> wrote:
Is there a way to set the background color for projection plots? I'd like to set it to be black instead of white, which I assume is the default.
That's right, following matplotlib's defaults.
There are two options to create a plot with a black background color. The first is to pass the 'facecolor' keyword argument down to matplotlib when calling the save function. Unfortunately since the foreground is black by default, you'll also have to adjust the colors of all of the axes, tick marks, axes text, colorbars, etc to be white. Here is an example notebook that does this: http://nbviewer.ipython.org/gist/ngoldbaum/7367380cbe6683159da5
Another option would be to adjust the matplotlib defaults in your matplotlibrc (http://matplotlib.org/1.3.1/users/customizing.html) so that figures have a black background by default.
I have to say that I kind of like the way the black background looks and could definitely see it being useful in some situations. I don't think it would be very hard to add a "set_black_theme" function that does more or less what my notebook does. That would probably be a nice afternoon hack for someone that wanted to familiarize themselves with yt's plotting code.
Hope that's helpful,
Nathan
Thanks, Andrew E. -- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Graduate Student Columbia University Department of Astronomy
Hi Andrew, There are ways to tell matplotlib to do this. I am away for a few days but the ones I remember are set_under and set_over but there's one for nans too. These get called on the color map object. Matt On May 29, 2014 10:42 AM, "Andrew James Emerick" <emerick@astro.columbia.edu> wrote:
Nathan & Christine,
Thanks for the fixes. The 'dumb' solution is the one I was planning on doing if there wasn't a more attractive option, but I wanted to see if there was a built-in way to do this without changing the field values.
Nathan: I do like your solution, and I do like the way the white on black looks in the plot. Its probably not universally useful, but I can imagine using it in some cases. Is there any way to do the matplotlib level commands though such that its just the background within the plot itself that changes (keeping the plot borders white). Basically doing what Christine suggested without editing the fields.
Andrew E.
On Wed, May 28, 2014 at 5:00 PM, Christine Simpson < csimpson@astro.columbia.edu> wrote:
A third rather dumb solution that I use is to add a tinny-tiny number to the field I’m projecting. I assume you are getting the white where the field is zero? If you are using a color bar with black as the color for the lowest value (like 'gray’), this will give you black where the field you are projecting is zero (or rather tinny-tiny).
Christine
On May 28, 2014, at 2:51 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Andrew,
On Wed, May 28, 2014 at 1:12 PM, Andrew James Emerick < emerick@astro.columbia.edu> wrote:
Is there a way to set the background color for projection plots? I'd like to set it to be black instead of white, which I assume is the default.
That's right, following matplotlib's defaults.
There are two options to create a plot with a black background color. The first is to pass the 'facecolor' keyword argument down to matplotlib when calling the save function. Unfortunately since the foreground is black by default, you'll also have to adjust the colors of all of the axes, tick marks, axes text, colorbars, etc to be white. Here is an example notebook that does this: http://nbviewer.ipython.org/gist/ngoldbaum/7367380cbe6683159da5
Another option would be to adjust the matplotlib defaults in your matplotlibrc (http://matplotlib.org/1.3.1/users/customizing.html) so that figures have a black background by default.
I have to say that I kind of like the way the black background looks and could definitely see it being useful in some situations. I don't think it would be very hard to add a "set_black_theme" function that does more or less what my notebook does. That would probably be a nice afternoon hack for someone that wanted to familiarize themselves with yt's plotting code.
Hope that's helpful,
Nathan
Thanks, Andrew E. -- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
On Thu, May 29, 2014 at 7:42 AM, Andrew James Emerick < emerick@astro.columbia.edu> wrote:
Nathan & Christine,
Thanks for the fixes. The 'dumb' solution is the one I was planning on doing if there wasn't a more attractive option, but I wanted to see if there was a built-in way to do this without changing the field values.
Nathan: I do like your solution, and I do like the way the white on black looks in the plot. Its probably not universally useful, but I can imagine using it in some cases. Is there any way to do the matplotlib level commands though such that its just the background within the plot itself that changes (keeping the plot borders white). Basically doing what Christine suggested without editing the fields.
Ah, well I guess my solution was a bit overkill, eh? What you want to do is actually quite simple: http://nbviewer.ipython.org/gist/ngoldbaum/494689db94a2b4e29781 Note that you might not want to use black as the facecolor - I would probably only use black if the colormap I was using had black as its lower bound. Another option would be to use a masked array and a custom colormap, e.g. following this: http://stackoverflow.com/questions/2578752/how-can-i-plot-nan-values-as-a-sp... To get this to work you'd need to add the colormap to yt's index of known colormaps.
Andrew E.
On Wed, May 28, 2014 at 5:00 PM, Christine Simpson < csimpson@astro.columbia.edu> wrote:
A third rather dumb solution that I use is to add a tinny-tiny number to the field I’m projecting. I assume you are getting the white where the field is zero? If you are using a color bar with black as the color for the lowest value (like 'gray’), this will give you black where the field you are projecting is zero (or rather tinny-tiny).
Christine
On May 28, 2014, at 2:51 PM, Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Andrew,
On Wed, May 28, 2014 at 1:12 PM, Andrew James Emerick < emerick@astro.columbia.edu> wrote:
Is there a way to set the background color for projection plots? I'd like to set it to be black instead of white, which I assume is the default.
That's right, following matplotlib's defaults.
There are two options to create a plot with a black background color. The first is to pass the 'facecolor' keyword argument down to matplotlib when calling the save function. Unfortunately since the foreground is black by default, you'll also have to adjust the colors of all of the axes, tick marks, axes text, colorbars, etc to be white. Here is an example notebook that does this: http://nbviewer.ipython.org/gist/ngoldbaum/7367380cbe6683159da5
Another option would be to adjust the matplotlib defaults in your matplotlibrc (http://matplotlib.org/1.3.1/users/customizing.html) so that figures have a black background by default.
I have to say that I kind of like the way the black background looks and could definitely see it being useful in some situations. I don't think it would be very hard to add a "set_black_theme" function that does more or less what my notebook does. That would probably be a nice afternoon hack for someone that wanted to familiarize themselves with yt's plotting code.
Hope that's helpful,
Nathan
Thanks, Andrew E. -- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Graduate Student Columbia University Department of Astronomy
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (4)
-
Andrew James Emerick
-
Christine Simpson
-
Matthew Turk
-
Nathan Goldbaum