Why pixel marker size is 4 pixels?

I noticed this a few years back, but left it aside because most of the
time I can live with it. Recently I need to make a few plots
containing a few million points, and 4 pixels for a point is a
disaster. So my question is why the pixel marker size is set at 4
pixels? And is there anyway to change it to a single pixel?

Thanks,
Chris

How are you plotting your points.

If you use *plot*, there is a *markersize* parameter.
If you use *scatter*, the third argument controls the marker size.

But you may actually complaining about other issues, e.g.,
antialiasing, etc. So, if above are not your answer, please post a
complete example and describe your problem in more detail.

Regards,

-JJ

···

On Sat, Feb 4, 2012 at 2:15 PM, Chris <plutino@...287...> wrote:

I noticed this a few years back, but left it aside because most of the
time I can live with it. Recently I need to make a few plots
containing a few million points, and 4 pixels for a point is a
disaster. So my question is why the pixel marker size is set at 4
pixels? And is there anyway to change it to a single pixel?

Thanks,
Chris

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks JJ.

The problem seems not to be a size issue -- markersize has no effect
when use marker="," (pixel). I have also tried to turn off aa, and it
doesn't help either. I also tried different backends. The PNG output
from Agg and Cairo is slightly different: Agg's point has 4 solid
pixel, while Cairo's has 4 pixel with random shade.

Postscript output has the same problem. The "pixel" in an EPS file
generated by mpl is significantly bigger than that from another
drawing program I used.

The problem occurs in all my plotting scripts, e.g., this basic one:

[CODE]
import numpy as np

x=np.arange(100)
y=np.random.randn(100)

ioff()
fig=gcf()
fig.clf()

ax=fig.add_axes(0.15,0.1,0.8, 0.85)
ax.plot(x,y,"k,")

ion()
fig.canvas.draw()
[/CODE]

Here is how I identify the problem:
1. use the above script to plot on screen
2. savefig("plot.png")
3. open plot.png in GIMP and check the pixel size.

I also attached the two PNG files generated with Agg and Cairo backends.

···

On Sun, Feb 5, 2012 at 6:45 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

How are you plotting your points.

If you use *plot*, there is a *markersize* parameter.
If you use *scatter*, the third argument controls the marker size.

But you may actually complaining about other issues, e.g.,
antialiasing, etc. So, if above are not your answer, please post a
complete example and describe your problem in more detail.

Regards,

-JJ

On Sat, Feb 4, 2012 at 2:15 PM, Chris <plutino@...287...> wrote:

I noticed this a few years back, but left it aside because most of the
time I can live with it. Recently I need to make a few plots
containing a few million points, and 4 pixels for a point is a
disaster. So my question is why the pixel marker size is set at 4
pixels? And is there anyway to change it to a single pixel?

Thanks,
Chris

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks. Now I understand the situation.

As far as I can see, marker="," is implemented as a rectangle path
with width/height of 1 pixel, so this result in 2x2 pixel filled
square.
I tried to change the size of the rectangle, etc, to get a single
pixel filled square, but did not get a satisfactory result.
I think we need an Agg expert. I hope Mike or others take a look.

Chris,
if you do not get a response from others in this mailing list, I
recommend you to open a new issue in our github page.

Regards,

-JJ

···

On Mon, Feb 6, 2012 at 1:53 AM, Chris <plutino@...287...> wrote:

Thanks JJ.

The problem seems not to be a size issue -- markersize has no effect
when use marker="," (pixel). I have also tried to turn off aa, and it
doesn't help either. I also tried different backends. The PNG output
from Agg and Cairo is slightly different: Agg's point has 4 solid
pixel, while Cairo's has 4 pixel with random shade.

Postscript output has the same problem. The "pixel" in an EPS file
generated by mpl is significantly bigger than that from another
drawing program I used.

The problem occurs in all my plotting scripts, e.g., this basic one:

[CODE]
import numpy as np

x=np.arange(100)
y=np.random.randn(100)

ioff()
fig=gcf()
fig.clf()

ax=fig.add_axes(0.15,0.1,0.8, 0.85)
ax.plot(x,y,"k,")

ion()
fig.canvas.draw()
[/CODE]

Here is how I identify the problem:
1. use the above script to plot on screen
2. savefig("plot.png")
3. open plot.png in GIMP and check the pixel size.

I also attached the two PNG files generated with Agg and Cairo backends.

On Sun, Feb 5, 2012 at 6:45 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

How are you plotting your points.

If you use *plot*, there is a *markersize* parameter.
If you use *scatter*, the third argument controls the marker size.

But you may actually complaining about other issues, e.g.,
antialiasing, etc. So, if above are not your answer, please post a
complete example and describe your problem in more detail.

Regards,

-JJ

On Sat, Feb 4, 2012 at 2:15 PM, Chris <plutino@...287...> wrote:

I noticed this a few years back, but left it aside because most of the
time I can live with it. Recently I need to make a few plots
containing a few million points, and 4 pixels for a point is a
disaster. So my question is why the pixel marker size is set at 4
pixels? And is there anyway to change it to a single pixel?

Thanks,
Chris

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Chris,

You might want to try a module written by Tom Robitaille (aka astrofrog)
called rasterized_scatter. Look for it on github.

Jon

···

On Mon, 2012-02-06 at 21:28 +0900, Jae-Joon Lee wrote:

Thanks. Now I understand the situation.

As far as I can see, marker="," is implemented as a rectangle path
with width/height of 1 pixel, so this result in 2x2 pixel filled
square.
I tried to change the size of the rectangle, etc, to get a single
pixel filled square, but did not get a satisfactory result.
I think we need an Agg expert. I hope Mike or others take a look.

Chris,
if you do not get a response from others in this mailing list, I
recommend you to open a new issue in our github page.

Regards,

-JJ

On Mon, Feb 6, 2012 at 1:53 AM, Chris <plutino@...287...> wrote:
> Thanks JJ.
>
> The problem seems not to be a size issue -- markersize has no effect
> when use marker="," (pixel). I have also tried to turn off aa, and it
> doesn't help either. I also tried different backends. The PNG output
> from Agg and Cairo is slightly different: Agg's point has 4 solid
> pixel, while Cairo's has 4 pixel with random shade.
>
> Postscript output has the same problem. The "pixel" in an EPS file
> generated by mpl is significantly bigger than that from another
> drawing program I used.
>
> The problem occurs in all my plotting scripts, e.g., this basic one:
>
> [CODE]
> import numpy as np
>
> x=np.arange(100)
> y=np.random.randn(100)
>
> ioff()
> fig=gcf()
> fig.clf()
>
> ax=fig.add_axes(0.15,0.1,0.8, 0.85)
> ax.plot(x,y,"k,")
>
> ion()
> fig.canvas.draw()
> [/CODE]
>
> Here is how I identify the problem:
> 1. use the above script to plot on screen
> 2. savefig("plot.png")
> 3. open plot.png in GIMP and check the pixel size.
>
> I also attached the two PNG files generated with Agg and Cairo backends.
>
>
> On Sun, Feb 5, 2012 at 6:45 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:
>> How are you plotting your points.
>>
>> If you use *plot*, there is a *markersize* parameter.
>> If you use *scatter*, the third argument controls the marker size.
>>
>> But you may actually complaining about other issues, e.g.,
>> antialiasing, etc. So, if above are not your answer, please post a
>> complete example and describe your problem in more detail.
>>
>> Regards,
>>
>> -JJ
>>
>>
>> On Sat, Feb 4, 2012 at 2:15 PM, Chris <plutino@...287...> wrote:
>>> I noticed this a few years back, but left it aside because most of the
>>> time I can live with it. Recently I need to make a few plots
>>> containing a few million points, and 4 pixels for a point is a
>>> disaster. So my question is why the pixel marker size is set at 4
>>> pixels? And is there anyway to change it to a single pixel?
>>>
>>> Thanks,
>>> Chris

I'm looking into the source of this bug now.

Mike

···

On 02/06/2012 09:19 AM, Jonathan Slavin wrote:

Chris,

You might want to try a module written by Tom Robitaille (aka astrofrog)
called rasterized_scatter. Look for it on github.

Jon

On Mon, 2012-02-06 at 21:28 +0900, Jae-Joon Lee wrote:

Thanks. Now I understand the situation.

As far as I can see, marker="," is implemented as a rectangle path
with width/height of 1 pixel, so this result in 2x2 pixel filled
square.
I tried to change the size of the rectangle, etc, to get a single
pixel filled square, but did not get a satisfactory result.
I think we need an Agg expert. I hope Mike or others take a look.

Chris,
if you do not get a response from others in this mailing list, I
recommend you to open a new issue in our github page.

Regards,

-JJ

On Mon, Feb 6, 2012 at 1:53 AM, Chris<plutino@...287...> wrote:

Thanks JJ.

The problem seems not to be a size issue -- markersize has no effect
when use marker="," (pixel). I have also tried to turn off aa, and it
doesn't help either. I also tried different backends. The PNG output
from Agg and Cairo is slightly different: Agg's point has 4 solid
pixel, while Cairo's has 4 pixel with random shade.

Postscript output has the same problem. The "pixel" in an EPS file
generated by mpl is significantly bigger than that from another
drawing program I used.

The problem occurs in all my plotting scripts, e.g., this basic one:

[CODE]
import numpy as np

x=np.arange(100)
y=np.random.randn(100)

ioff()
fig=gcf()
fig.clf()

ax=fig.add_axes(0.15,0.1,0.8, 0.85)
ax.plot(x,y,"k,")

ion()
fig.canvas.draw()
[/CODE]

Here is how I identify the problem:
1. use the above script to plot on screen
2. savefig("plot.png")
3. open plot.png in GIMP and check the pixel size.

I also attached the two PNG files generated with Agg and Cairo backends.

On Sun, Feb 5, 2012 at 6:45 AM, Jae-Joon Lee<lee.j.joon@...287...> wrote:

How are you plotting your points.

If you use *plot*, there is a *markersize* parameter.
If you use *scatter*, the third argument controls the marker size.

But you may actually complaining about other issues, e.g.,
antialiasing, etc. So, if above are not your answer, please post a
complete example and describe your problem in more detail.

Regards,

-JJ

On Sat, Feb 4, 2012 at 2:15 PM, Chris<plutino@...287...> wrote:

I noticed this a few years back, but left it aside because most of the
time I can live with it. Recently I need to make a few plots
containing a few million points, and 4 pixels for a point is a
disaster. So my question is why the pixel marker size is set at 4
pixels? And is there anyway to change it to a single pixel?

Thanks,
Chris

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

JJ,

Thanks for the clarification. Now I understand why EPS outputs of
pixel plot from mpl is a few times bigger than those from SuperMongo.
I guess that mpl uses the square implementation for pixel so that it
would use the same method to handle all marker types. I will file an
issue report on git. Meanwhile, is there any easy workaround?

Jonathan,

Tom Robitaille's module does help reducing file size of postscript,
but by rasterize a scalable plot. It doesn't really help my problem
since the markers are still drawn with the same method as other
plotting methods.

Bests,
Chris

···

On Mon, Feb 6, 2012 at 4:28 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

Thanks. Now I understand the situation.

As far as I can see, marker="," is implemented as a rectangle path
with width/height of 1 pixel, so this result in 2x2 pixel filled
square.
I tried to change the size of the rectangle, etc, to get a single
pixel filled square, but did not get a satisfactory result.
I think we need an Agg expert. I hope Mike or others take a look.

Chris,
if you do not get a response from others in this mailing list, I
recommend you to open a new issue in our github page.

Regards,

-JJ

On Mon, Feb 6, 2012 at 6:19 AM, Jonathan Slavin <jslavin@...1081...> wrote:

Chris,

You might want to try a module written by Tom Robitaille (aka astrofrog)
called rasterized_scatter. Look for it on github.

Jon

On Mon, 2012-02-06 at 21:28 +0900, Jae-Joon Lee wrote:

Thanks. Now I understand the situation.

As far as I can see, marker="," is implemented as a rectangle path
with width/height of 1 pixel, so this result in 2x2 pixel filled
square.
I tried to change the size of the rectangle, etc, to get a single
pixel filled square, but did not get a satisfactory result.
I think we need an Agg expert. I hope Mike or others take a look.

Chris,
if you do not get a response from others in this mailing list, I
recommend you to open a new issue in our github page.

Regards,

-JJ

On Mon, Feb 6, 2012 at 1:53 AM, Chris <plutino@...287...> wrote:
> Thanks JJ.
>
> The problem seems not to be a size issue -- markersize has no effect
> when use marker="," (pixel). I have also tried to turn off aa, and it
> doesn't help either. I also tried different backends. The PNG output
> from Agg and Cairo is slightly different: Agg's point has 4 solid
> pixel, while Cairo's has 4 pixel with random shade.
>
> Postscript output has the same problem. The "pixel" in an EPS file
> generated by mpl is significantly bigger than that from another
> drawing program I used.
>
> The problem occurs in all my plotting scripts, e.g., this basic one:
>
> [CODE]
> import numpy as np
>
> x=np.arange(100)
> y=np.random.randn(100)
>
> ioff()
> fig=gcf()
> fig.clf()
>
> ax=fig.add_axes(0.15,0.1,0.8, 0.85)
> ax.plot(x,y,"k,")
>
> ion()
> fig.canvas.draw()
> [/CODE]
>
> Here is how I identify the problem:
> 1. use the above script to plot on screen
> 2. savefig("plot.png")
> 3. open plot.png in GIMP and check the pixel size.
>
> I also attached the two PNG files generated with Agg and Cairo backends.
>
>
> On Sun, Feb 5, 2012 at 6:45 AM, Jae-Joon Lee <lee.j.joon@...287...> wrote:
>> How are you plotting your points.
>>
>> If you use *plot*, there is a *markersize* parameter.
>> If you use *scatter*, the third argument controls the marker size.
>>
>> But you may actually complaining about other issues, e.g.,
>> antialiasing, etc. So, if above are not your answer, please post a
>> complete example and describe your problem in more detail.
>>
>> Regards,
>>
>> -JJ
>>
>>
>> On Sat, Feb 4, 2012 at 2:15 PM, Chris <plutino@...287...> wrote:
>>> I noticed this a few years back, but left it aside because most of the
>>> time I can live with it. Recently I need to make a few plots
>>> containing a few million points, and 4 pixels for a point is a
>>> disaster. So my question is why the pixel marker size is set at 4
>>> pixels? And is there anyway to change it to a single pixel?
>>>
>>> Thanks,
>>> Chris

There is a pull request for this here:

https://github.com/matplotlib/matplotlib/pull/695

If you're able to checkout and build that branch from git, I would

appreciate hearing if it resolves your issue.

Mike
···

<lee.j.joon@…287…><jslavin@…1081…><plutino@…287…><lee.j.joon@…287…><plutino@…287…>http://p.sf.net/sfu/learndevnow-dev2Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users