plotpixelrecordxrandr

Relationship between pixel and record on plotting a graph


Get my monitor's info with xrandr.

xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
VGA-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080     60.00*+

There are only 1920 pixels in the xaxis, only 1920 tiny boxes.

import matplotlib.pyplot as plt
y = 1*19200
x = range(0,len(x))
plt.scatter(x,y)
plt.show()

I draw a horizontal line that contains 19200 pairs of records. There are only 1920 pixels in the x axis, how to put 19200 items into 1920 boxes?
Does one pixel draw 10 x records? Put 10 x records into just one box? Ten different data records in just one pixel? How can one pixel express ten records?

Fix all my typo:

import matplotlib.pyplot as plt
y = [1]*19200
x = range(0,len(y))
plt.scatter(x,y)
plt.show()

It means that there are 19200 pairs of data record (x,y) to draw, but only at most 1920 pairs of data record really shown on the monitor in this case ?
How many pixel to draw the ten pairs (x,y) data record :(0,1) ,(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1) in my case? In my point of view,only one pixel to draw the ten pairs (x,y) data record,that is to say ,only one pair (x,y) data record was drawn into one pixel,in x axis direction,there are only 1920 pixels,one pixel draw one pair of (x,y) record,you need 19200 pixels in x axis direction.


Solution

  • The code you've posted doesn't run. At least there is no x to take a len() of. So probably it should look like this:

    import matplotlib.pyplot as plt
    
    y = [1]*19200
    x = range(0,19200)
    
    plt.scatter(x,y)
    plt.show()
    

    But that way it just draws a line.
    enter image description here

    Even if you'd have a monitor with 19200 pixels you'll still see a line with a dot in every pixels of it.
    enter image description here

    So I suppose you've actually meant something like this:

    import matplotlib.pyplot as plt
    import numpy as np
    
    L = 19200
    
    y = [1]*L
    x = [v*(i+1) for i, v in enumerate(np.random.randint(0,2,L))]
    
    plt.scatter(x,y,alpha=0.5)
    plt.show()
    

    On a really big monitor it would look like this:
    enter image description here

    And of course you can't show separate points in one pixel, but you can show how many points fit into one particular pixel. Just add another dimension to your plot.

    As your plot is just a line and you don't really utilize y axis you can use it as an extra dimension:

    x = np.random.randint(0,2,size=(L,10))
    y = np.sum(x,axis=1)
    x = range(0,L)
    
    plt.fill_between(x,y, alpha=0.5)
    plt.show()
    

    It will give:
    enter image description here

    Height of a bar represents number of points in a pixel.

    Or if you really want a line you can use color as an extra dimension:

    x = np.random.randint(0,2,size=(L,10))
    colors = [[(1,1,1),(0,0,1),(0,0.5,1),(0,1,1),(0,1,0.5),(0,1,0),(0.5,1,0),(1,1,0),(1,0.5,0),(1,0,0)][v] for v in np.sum(x,axis=1)]
    # or if your prefer monochrome
    # colors = [(1,0,0,v/10) for v in np.sum(x,axis=1)]
    x = range(0,L)
    y = [1]*L
    
    plt.scatter(x,y, c=colors, s=3)
    plt.show()
    

    It gives:
    enter image description here

    Monochrome version:
    enter image description here

    You can play with it here

    As images are even smaller that 1920 I played with the L to make them more vivid on a random data.

    Update:

    There are 3 points in the first group of pixels. And there is one point in the second.

    Image: [img]

    How many points do you see in the third group?

    If you have a good eyesight and a big screen you'll see that there are 2 point.

    But what if you have a poor eyesight, a small screen, or if you'll just step away from the screen. Can you still tell how many points are there? Yes, you can!

    To some extent, of course. If you'll stand in 1Km from the screen you'll probably won't be able to see the screen itself :)

    But how can you tell? By the weight of the group - it looks lighter than the first one and darker than the second.

    Now, show the next image to someone and tell that the first group has tree pixels. Then ask: how many pixels are in other groups?

    Image: [img]

    They'll probably tell you that there are 2 and 1 pixels in those group. But that's not true. There are same number of pixels. The only difference is that those pixels have different color.

    So, it doesn't really matters how many pixels you'll draw. What matters is how they perceived.

    But more than that... You say "pixel", but is it a dot? No! In most cases there are 3 dots of different color.

    enter image description here

    So if you see a red pixel you can be sure that there is one dot lighten up. If you see yellow - there are 2 dots lighten up. Etc. Judging by the color you can even say exactly which of the dots constituting the pixel are highlighted.

    But again - does it really matter? If you'll just say: "this particular color means (0,1)(1,1)(2,1), and this particular color means (3,1)(4,1), etc." people will understand your plot regardless of monitors and their resolutions.

    But, again, more than that: when you draw a pixel on your monitor it is not even a single physical pixel and not just 3 dots. You monitor has a maximum resolution of 8192*8192... so there is more that 8 physical pixels for a one logical on resolution 1920*1080. And this actually gives more than 16 physical pixels for one logical. So can you

    Put 10 x records into just one box?

    ...as you can see, the "box" is quite big. You can put 16 records into it. Physically. And logically you can add even more.