Horizontal drawplot() !

/*
| plotting function for the trigplotter program.
| 2020-09-16
*/
#include <stdio.h>

// Use different symbols for positive, negative slopes:
#define UP      "^"
#define DOWN    "v"

#define RANGE   2.0
#define NUMROWS 44.0
#define ROWHEIGHT ((double)RANGE / (double)NUMROWS)

double height(int row)
{
    return (row * ROWHEIGHT - 1.0);
}

void drawplot(double *ftn, int nsteps, int width)
{
    double indexstep = (double)nsteps / (double)width;

    // Draw top border:
    for (int col = 0; col < width; col++)
        printf("+");
    printf("\n");

    for (int row = NUMROWS; row >= 0; row--) {
        printf("%6.3lf", height(row));

        for (int col = 0; col < width-12; col++) {
            unsigned idx = col * indexstep;

            /*
            | Compare ftn values at current, and next indexes to
            | determine positive/negative slope over local "delta-x".
            |
            | Compare ftn values against previous, next rows,
            | instead of the current and next row,
            | in order to "smear" the drawn curve over a couple of rows.
            */

            // curve w/ positive slope?
            if (ftn[idx] <= height(row+1)
                        && ftn[idx+1] >= height(row-1))
                printf(UP);

            // curve w/ negative slope?
            else if (ftn[idx] >= height(row-1)
                        && ftn[idx+1] <= height(row+1))
                printf(DOWN);

            // 0-axis?
            else if (row == NUMROWS/2)
                printf("-");

            // this point isn't near the curve:
            else
                printf(" ");
        }
        printf("%6.3lf", height(row));
        printf("\n");
    }

    // Draw bottom border:
    for (int col = 0; col < width; col++)
        printf("+");
    printf("\n");
}
//----------------------------------------------------------------

Example output

Graph of function:

double trigfunct(double x)
{
    double beats = 9.5;
    //return  sin(x) * cos(beats * x);    // Or some other interesting function...
    return  sin(x) * cos(beats*pow(x, 1.1)) * exp(-x/10.0);
}