[PYTHON] About the size of matplotlib points

Python's matplotlib is so convenient that I'm always indebted. I can't sleep with my feet turned, but today I'd like to give a little test on the size of the "dots".

%matplotlib inline
import matplotlib.pyplot as plt

Draw a dot

plt.scatter(0, 0, c='k')

output_1_2.png

Draw a big dot

plt.scatter(0, 0, c='k', s=1000)

output_2_1.png

Increase points

It looks like the size of the dots has changed a little here. The size of the point at the origin should not have changed, but this size is just the size of the display size and does not seem to correspond to the size of the coordinates.

plt.scatter(0, 0, c='k', s=1000)
plt.scatter(0.1, 0.1, c='k', s=700)
plt.scatter(-0.1, 0.1, c='k', s=700)

output_3_1.png

Change the display area of the image

So, if you change the coordinate range where the image is displayed, it will look completely different. It has become like a water molecule.

plt.xlim([-1, 1])
plt.ylim([-1, 1])
plt.scatter(0, 0, c='k', s=1000)
plt.scatter(0.1, 0.1, c='k', s=700)
plt.scatter(-0.1, 0.1, c='k', s=700)

output_4_1.png

Change the aspect ratio of the image

Even if you change the aspect ratio of the image, the shape will look different as well. It looks like a water molecule.

plt.figure(figsize=(8,8))
plt.xlim([-1, 1])
plt.ylim([-1, 1])
plt.scatter(0, 0, c='k', s=1000)
plt.scatter(0.1, 0.1, c='k', s=700)
plt.scatter(-0.1, 0.1, c='k', s=700)

output_5_1.png

Change the size of the image

Even if you change the size of the image, the shape will look different as well. It looks like a water molecule.

plt.figure(figsize=(6,6))
plt.xlim([-1, 1])
plt.ylim([-1, 1])
plt.scatter(0, 0, c='k', s=1000)
plt.scatter(0.1, 0.1, c='k', s=700)
plt.scatter(-0.1, 0.1, c='k', s=700)

output_6_1.png

Make a lot of duplicates

Let's move the same thing horizontally and draw a lot of duplicates. that? Ears ... not ... hydrogen atoms? I can't see anything like that.

plt.figure(figsize=(6,6))
plt.xlim([-10, 10])
plt.ylim([-10, 10])
for x in [-5, 0, 5]:
    for y in [-5, 0, 5]:
        plt.scatter(0 + x, 0 + y, c='k', s=1200)
        plt.scatter(0.1 + x, 0.1 + y, c='k', s=700)
        plt.scatter(-0.1 + x, 0.1 + y, c='k', s=700)
plt.show()

output_7_0.png

Mi ... In order to return to the shape of water molecules, it is necessary to review the positional relationship.

plt.figure(figsize=(6,6))
plt.xlim([-10, 10])
plt.ylim([-10, 10])
for x in [-5, 0, 5]:
    for y in [-5, 0, 5]:
        plt.scatter(0 + x, 0 + y, c='k', s=1000)
        plt.scatter(1 + x, 1 + y, c='k', s=700)
        plt.scatter(-1 + x, 1 + y, c='k', s=700)
plt.show()

output_8_0.png

Summary

Matplotlib is useful, but it's a bit annoying to get a nice dot size.

Recommended Posts

About the size of matplotlib points
Align the size of the colorbar with matplotlib
About the X-axis notation of Matplotlib bar graphs
Increase the font size of the graph with matplotlib
About the ease of Python
Change the style of matplotlib
About the components of Luigi
About the features of Python
About the return value of pthread_mutex_init ()
About the return value of the histogram.
About the basic type of Go
About the upper limit of threads-max
Increase the UI size of MyPaint
About the behavior of yield_per of SqlAlchemy
About the basics list of Python basics
[pyqtgraph] Set the size ratio of the graph
About the behavior of enable_backprop of Chainer v2
About the virtual environment of python version 3.7
About the arguments of the setup function of PyCaret
About the Normal Equation of Linear Regression
Tips: Comparison of the size of three values
[Python] How to specify the window display position and size of matplotlib
About the test
About the queue
About the accuracy of Archimedean circle calculation method
About the behavior of copy, deepcopy and numpy.copy
One liner that lists the colors of matplotlib
A note about the python version of python virtualenv
About the development contents of machine learning (Example)
[Note] About the role of underscore "_" in Python
Put the second axis in 2dhistgram of matplotlib
About the behavior of Model.get_or_create () of peewee in Python
The basis of graph theory with matplotlib animation
Code for checking the operation of Python Matplotlib
Visualize the behavior of the sorting algorithm with matplotlib
About the behavior of Queue during parallel processing
About the * (asterisk) argument of python (and itertools.starmap)
The beginning of cif2cell
A memorandum about the warning of the pylint output result
About all of numpy
Add information to the bottom of the figure with Matplotlib
The meaning of self
A memorandum about matplotlib
About assignment of numpy.ndarray
Omit the decimal point of the graph scale in matplotlib
About MultiIndex of pandas
the zen of Python
Reduction of slug size
Think about the next generation of Rack and WSGI
About testing in the implementation of machine learning models
Python points from the perspective of a C programmer
About the inefficiency of data transfer in luigi on-memory
Get the size (number of elements) of UnionFind in Python
About the Unfold function
About the service command
About the uncluttered arrangement in the import order of flake8
A story about changing the master name of BlueZ
About variable of chainer
About the confusion matrix
About the Visitor pattern
Personal notes about the integration of vscode and anaconda