limit axis in one direction plt

To limit the axis in one direction using plt in C, you can use the plt.xlim() or plt.ylim() functions. These functions allow you to specify the minimum and maximum values for the x or y axis, respectively.

Here is an example of how to limit the x-axis:

#include <stdio.h>
#include <math.h>
#include <matplotlib.pyplot.h>

int main() {
    float x[100], y[100];
    int i;

    for (i = 0; i < 100; i++) {
        x[i] = i;
        y[i] = sin(x[i]);
    }

    // Plotting the graph
    plt.plot(x, y);

    // Limiting the x-axis
    plt.xlim(0, 10);

    // Displaying the graph
    plt.show();

    return 0;
}

In this example, the plt.xlim(0, 10) function limits the x-axis to the range from 0 to 10. You can modify the values passed to plt.xlim() to set the desired range for the x-axis.

Similarly, you can use the plt.ylim() function to limit the y-axis in the same way.