Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to adjust the point size in a matplotlib cartesian coordinate system

Does anyone know how to adjust the size of the points in the coordinate system. Furthermore it would be great if it were possible to use little crosses instead of dots to display the points.

import numpy as np                 
import matplotlib.pyplot as plt    

# Enter x and y coordinates of points and colors
xs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
ys = [64, 72, 47, 38, 55, 30, 47, 64, 73, 30, 55, 64, 38, 47, 73, 55, 38, 30, 72, 47, 63, 73, 47, 44, 38, 55, 30, 38, 55, 72, 47, 38, 65, 47, 38, 63, 30, 55, 72, 55, 47, 53, 73, 30, 38, 55, 30, 38, 64, 73]
colors = ['g']

# Select length of axes and the space between tick labels
xmin, xmax, ymin, ymax = 0, 50, 0, 80
ticks_frequency = 5

# Plot points
fig, ax = plt.subplots(figsize=(10, 10))
ax.scatter(xs, ys, c=colors)

# Set identical scales for both axes
ax.set(xlim=(xmin-1, xmax+1), ylim=(ymin-1, ymax+1), aspect='equal')

# Remove top and right spines
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

# Create 'x' and 'y' labels placed at the end of the axes
ax.set_xlabel('n', size=14, labelpad=-24, x=1.03)
ax.set_ylabel('t in s', size=14, labelpad=-21, y=1.02, rotation=0)

# Create custom major ticks to determine position of tick labels
x_ticks = np.arange(xmin, xmax+1, ticks_frequency)
y_ticks = np.arange(ymin, ymax+1, ticks_frequency)
ax.set_xticks(x_ticks[x_ticks != 0])
ax.set_yticks(y_ticks[y_ticks != 0])

# Create minor ticks placed at each integer to enable drawing of minor grid
# lines: note that this has no effect in this example with ticks_frequency=1
ax.set_xticks(np.arange(xmin, xmax+1), minor=True)
ax.set_yticks(np.arange(ymin, ymax+1), minor=True)

# Draw major and minor grid lines
ax.grid(which='both', color='grey', linewidth=1, linestyle='-', alpha=0.2)



plt.show()

Have a great day!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to specify a different marker and markersize to your plot arguments:

ax.scatter(xs, ys, c=colors, marker='x', s=5) #may need to fiddle with the s value to get what you want (not that it's the area of the marker, not its linear size)

See https://matplotlib.org/stable/api/markers_api.html for all the available markers, there are many.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading