Issue
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()
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.
Answered By - Learning is a mess
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.