Re: [Matplotlib-users] Looking for feedback on figures using matplotlib and jupyter notebook

2016-01-28 Thread Benjamin Root
In mpl, our figure objects get numbers assigned to them by default, but
they can also be strings. These labels are used in the figure window title
bar. Perhaps that existing data could be hijacked? Admittedly, most people
use the string name to give nice short names to their figures, so maybe
those names could be the "tag" name in latex? So, all we would need is some
way to supply the actual caption string.

Ben Root


On Thu, Jan 28, 2016 at 10:17 PM, Fernando Perez 
wrote:

> On Thu, Jan 28, 2016 at 3:23 PM, Andreas Mueller  wrote:
>
>> Hi all.
>>
>> This is about a joint jupyter-notebook / matplotlib problem I've been
>> thinking about.
>> So I'm writing a book using jupyter-notebook, and all my figures are
>> generated using matplotlib.
>>
>> In books, there is usually a figure caption with a running number and
>> some description.
>>  From what I read, the best way to add captions is just using plt.text.
>> However, the caption should probably be in the markup,
>> not in a rendered PNG. I'm not sure if changing the backend might help,
>> but that probably doesn't make the notebook happy?
>>
>> The other problem is that I want to have running numbers that I can
>> refer to by a tag (as you would in latex).
>> That is more of a notebook problem, though.
>>
>> Any feedback would be very welcome
>>
>
> I've been wanting to do something about this problem for a while, but
> haven't had the cycles to work on it...  Here's my current idea, perhaps I
> can goad you into implementing it :)
>
> I think that IPython.display should provide a Figure object, capable of
> wrapping any input image (with nice code to automatically swallow a
> matplotlib figure without asking the user to convert it to an image first),
> and taking an optional caption.
>
> Figure() would then produce as output the displayed image but with a bit
> of nice CSS to center it on the page, along with the caption.
>
> The trick is to send the entire data bundle correctly structured so that,
> at the other end, nbconvert could recognize these figures as such, and not
> only produce nice HTML, but more importantly, push them into the LaTeX
> output with the correct call to \figure, including \caption as well as size
> and placement specifiers.
>
> The signature of Figure() might be something like
>
> def Figure(fig, caption=None, width=None, height=None,
>latex_placement=None):
>
>
> I would try implementing this first as a standalone tool, and once it's
> been tested enough in real-world usage with both HTML and LaTeX output from
> nbconvert, it could be merged in.  I suspect it's going to take a few
> iterations to get it right.
>
> But it's not particularly hard, and someone working on a book would be the
> perfect candidate to have enough test cases to be able to iterate until
> happy ;)
>
> If you think you want to take a stab at this, don't hesitate to ping us on
> the jupyter list. We can help with some of the more obscure parts of
> getting this to work on nbconvert (and there may be things I've overlooked
> in the sketch above).
>
> Cheers,
>
> f
>
> --
> Fernando Perez (@fperez_org; http://fperez.org)
> fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
> fernando.perez-at-berkeley: contact me here for any direct mail
>
>
> --
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Looking for feedback on figures using matplotlib and jupyter notebook

2016-01-28 Thread Fernando Perez
On Thu, Jan 28, 2016 at 3:23 PM, Andreas Mueller  wrote:

> Hi all.
>
> This is about a joint jupyter-notebook / matplotlib problem I've been
> thinking about.
> So I'm writing a book using jupyter-notebook, and all my figures are
> generated using matplotlib.
>
> In books, there is usually a figure caption with a running number and
> some description.
>  From what I read, the best way to add captions is just using plt.text.
> However, the caption should probably be in the markup,
> not in a rendered PNG. I'm not sure if changing the backend might help,
> but that probably doesn't make the notebook happy?
>
> The other problem is that I want to have running numbers that I can
> refer to by a tag (as you would in latex).
> That is more of a notebook problem, though.
>
> Any feedback would be very welcome
>

I've been wanting to do something about this problem for a while, but
haven't had the cycles to work on it...  Here's my current idea, perhaps I
can goad you into implementing it :)

I think that IPython.display should provide a Figure object, capable of
wrapping any input image (with nice code to automatically swallow a
matplotlib figure without asking the user to convert it to an image first),
and taking an optional caption.

Figure() would then produce as output the displayed image but with a bit of
nice CSS to center it on the page, along with the caption.

The trick is to send the entire data bundle correctly structured so that,
at the other end, nbconvert could recognize these figures as such, and not
only produce nice HTML, but more importantly, push them into the LaTeX
output with the correct call to \figure, including \caption as well as size
and placement specifiers.

The signature of Figure() might be something like

def Figure(fig, caption=None, width=None, height=None,
   latex_placement=None):


I would try implementing this first as a standalone tool, and once it's
been tested enough in real-world usage with both HTML and LaTeX output from
nbconvert, it could be merged in.  I suspect it's going to take a few
iterations to get it right.

But it's not particularly hard, and someone working on a book would be the
perfect candidate to have enough test cases to be able to iterate until
happy ;)

If you think you want to take a stab at this, don't hesitate to ping us on
the jupyter list. We can help with some of the more obscure parts of
getting this to work on nbconvert (and there may be things I've overlooked
in the sketch above).

Cheers,

f

-- 
Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Looking for feedback on figures using matplotlib and jupyter notebook

2016-01-28 Thread Andreas Mueller
Hi all.

This is about a joint jupyter-notebook / matplotlib problem I've been 
thinking about.
So I'm writing a book using jupyter-notebook, and all my figures are 
generated using matplotlib.

In books, there is usually a figure caption with a running number and 
some description.
 From what I read, the best way to add captions is just using plt.text. 
However, the caption should probably be in the markup,
not in a rendered PNG. I'm not sure if changing the backend might help, 
but that probably doesn't make the notebook happy?

The other problem is that I want to have running numbers that I can 
refer to by a tag (as you would in latex).
That is more of a notebook problem, though.

Any feedback would be very welcome.

Cheers,
Andy

--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Hide overlapping tick marks in axes corner

2016-01-28 Thread Julian Irwin
Hello,

I am looking for a way to hide tick marks (not the labels!) that coincide
with axis lines. I think this is a problem for me because of the relative
line thicknesses of my axis lines and tick marks, but I want to leave those
thicknesses unchanged (I like the look of the thickness settings I am using
now).

Here is a screenshot of what I'm talking about:

[image: Inline image 1]

I know this looks minor, but it is quite obvious on some plots and I'd
really like to get rid of it.

Thanks,
Julian Irwin
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] applying an image's colormap to another image

2016-01-28 Thread Fabrice Silva
Le mercredi 27 janvier 2016, Matteo Niccoli a écrit :
> Can something like this (which by the way I can't get to work):
> http://stackoverflow.com/questions/3114925/pil-convert-rgb-image-to-a
> -specific-8-bit-palette
> 
> What I would like to do is this:
> 1) Import an RGB image, which would have its own colormap - say this
> one for example:
> https://upload.wikimedia.org/wikipedia/commons/b/b3/Jupiter_new_hubble_view_above_pole.png

> 2) convert it to intensity, display the intensity color-mapped to the
> same colours the original RGB had.

According to the PNG header, this image does not have a palette (i.e. a
list of colors). The data chunks define the image as an array of NxMx3
values (N rows, M cols, 3 channels=no alpha), each value being defined
using 8 bits. I may however badly understand what you call the "own
colormap"...

You still can convert it to a grayscale img representing the intensity
(NxM values), but you then lose some information and you cannot display
it back with the same colors as originally. Because some different RGB
tuple are converted into the same intensity level, you can then not
discriminate them using the intensity image only.

Maybe there is some trick to convert to a grayscale image where those
RGB values are converted to almost-equal-but-different intensity levels
that would enable the later reconstruction, but I am not aware of...

Fabrice

--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] applying an image's colormap to another image

2016-01-28 Thread Benjamin Root
You might have better luck asking the scikit-image people, or the Pillow
people. ImageMagick might also have what you are looking for.

Cheers!
Ben Root


On Wed, Jan 27, 2016 at 11:23 PM, Matteo Niccoli  wrote:

> Can something like this (which by the way I can't get to work):
>
> http://stackoverflow.com/questions/3114925/pil-convert-rgb-image-to-a-specific-8-bit-palette
>
> What I would like to do is this:
> 1) Import an RGB image, which would have its own colormap - say this one
> for example:
>
> https://upload.wikimedia.org/wikipedia/commons/b/b3/Jupiter_new_hubble_view_above_pole.png
>
> 2) convert it to intensity, display the intensity color-mapped to the same
> colours the original RGB had.
>
> Any tips, or even better code or pseudocode would be greatly appreciated.
>
> Thanks
> Matteo
>
>
>
> --
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users