Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Prevent negative numbers on x-axis when using QCustomplot
Forum Updated to NodeBB v4.3 + New Features

Prevent negative numbers on x-axis when using QCustomplot

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kpks
    wrote on last edited by
    #1

    Hi,
    I am using qcustomplot to graph numbers coming over the tcp port from an embedded microprocessor.

    I am setting up my plot window as per the real time graph example:

    @plotW->addGraph(); // blue line
    plotW->graph(0)->setPen(QPen(Qt::blue));
    plotW->graph(0)->setBrush(QBrush(QColor(240, 255, 200)));
    plotW->graph(0)->setAntialiasedFill(false);
    plotW->addGraph(); // red line
    plotW->graph(1)->setPen(QPen(Qt::red));
    plotW->xAxis->setRangeLower(0.0);
    plotW->xAxis->setLabel("Time S");
    plotW->yAxis->setLabel("Compression Depth mm");
    plotW->xAxis->setRange(0.0,1.5,Qt::AlignLeft);
    plotW->yAxis->setRange(0,60);
    plotW->axisRect()->setupFullAxesBox();@

    and plot in the plotwindow when the data comes in:

    @double key = index/2000.0;//converts time to mS

    ui->plotW->replot();
    updateDepth(val);@

    When the graph window is created the plot window looks beautiful: 0 - 1.5 on X-Axis, 0 - 60 on y-axis.

    But when I actually start plotting the graph, the screen resizes to -1.5 to 0 on x-axis.
    How do I prevent the graph displaying -Ve values for the X-Axis which is actually time in ms, and -ve time would make no sense in my app?

    Thanks
    kpks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved