I want to plot nodes from 0 to 28 without including nodes from 2:9 I tried to use this command, but got syntax error:

plt.scatter(node_coords[0:2&&10:28,0], node_coords[0:28,1], color='red', s=70)

1 Answer 1


You can't use && when slicing, but you can use np.concatenate. Here's an example

import matplotlib.pyplot as plt
import numpy as np

node_coords = np.random.rand(28, 2)

selected_nodes = np.concatenate((node_coords[0:2], node_coords[10:28]))

plt.scatter(selected_nodes[:, 0], selected_nodes[:, 1], s=35)
  • 3
    $\begingroup$ I think it would be better to not provide answers to low-effort and off-topic questions like this to promote good question etiquitte $\endgroup$
    – whpowell96
    Dec 12, 2023 at 18:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.