'How to solve this error in xticks(missing) of scatter plot?

A scatter plot was plotted using matplotlib as below

    pl.title('Test Case 2.1')
    pl.scatter(df2['Cross Section'],df2['Distance'])
    pl.xlabel('Radar cross section [dBsm]')

    pl.xlim([-35, -45])
    pl.ylim(0, 65)

    pl.ylabel('Distance [m]')
    pl.xticks(np.arange(-35, -45,5))
    pl.yticks(np.arange(0, 63, 5))
    pl.grid()
    pl.show()

The x axis is missing the limits and xticks.The image is attachedenter image description here
How to solve this?



Solution 1:[1]

I'm not an expert in radars, so I'm going to assume you know what you are doing. Specifically, with pl.xlim([-35, -45]) you are setting a greater (absolute) value on the left, decreasing towards the right.

Now, to customize the xticks you are going to use:

plt.xticks(np.flip(np.arange(-45, -35, 1)))

It's left to you do decompose the previous command and see what each part is doing.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Davide_sd