title: Qt Charts, how to scale axis according to its values
body: <p>I have set of about 600 pairs of x and y value that should be plotted. They are read as doubles from a CSV file</p>
  
  <pre><code>void ChartView::getData4Series()
  {
  QFile file(QCoreApplication::applicationDirPath() + "/../saveData/" + m_videoPath + "/" + "SaveDisplace.csv");
  if (!file.open(QIODevice::ReadOnly))
  {
      QMessageBox::information(0, "error", file.errorString());
  }
  QTextStream in(&amp;file);
  QString line;
  QStringList fields;
  
  QtCharts::QScatterSeries* series = new QtCharts::QScatterSeries;
  m_seriesTy-&gt;clear();
  m_seriesTz-&gt;clear();
  bool checkforChar ;
  while (!in.atEnd())
  {
      line = in.readLine();
      fields = line.split(";");
      fields[2].toDouble(&amp;checkforChar);
      if (checkforChar)
      {
          if (fields[2].toDouble() &lt;= 100.0 &amp;&amp; fields[2].toDouble() &gt;= -5000.0)
          {
              if (fields[6].toDouble() &gt; -100000.0)
              {
                  m_seriesTy-&gt;append(fields[2].toDouble(), (fields[3].toDouble() - fields[6].toDouble()));
                  m_seriesTz-&gt;append(fields[2].toDouble(), (fields[4].toDouble() - fields[7].toDouble()));
              }
          }
      }
  
  }
  file.close();
  }
  </code></pre>
  
  <p>I set up the chart by setting the axis, given the limits and adding a further line (only 2 value pairs) as reference. </p>
  
  <pre><code>void ChartView::setZErrorCharts(QtCharts::QScatterSeries* series)
  {
  series-&gt;setMarkerSize(8);
  QtCharts::QValueAxis *xAxis = new QtCharts::QValueAxis;
  QtCharts::QValueAxis *yAxis = new QtCharts::QValueAxis;
  xAxis-&gt;setRange(-5000, 0);
  yAxis-&gt;setRange(-500, 500);
  
  QtCharts::QLineSeries* lineSeries = new QtCharts::QLineSeries;
  lineSeries-&gt;append(qreal(0), qreal(0));
  lineSeries-&gt;append(qreal(-5000), qreal(0));
  
  m_chartTzError = new QtCharts::QChart();
  
  m_chartTzError-&gt;setAxisX(xAxis);
  m_chartTzError-&gt;setAxisY(yAxis);
  m_chartTzError-&gt;setTitle("tz error ");
  
  m_chartTzError-&gt;legend()-&gt;hide();
  m_chartTzError-&gt;addSeries(series);
  m_chartTzError-&gt;addSeries(lineSeries);  
  </code></pre>
  
  <p>}</p>
  
  <p>What I can see is that the value of axis don't fit to the actual values of the plotted one. 
  I also plotted the values as labels and they also differ from the x and y axis values.
  How is the scaling of the axis arranged. I tried to mess aroud with the order, setting the range of the axis before adding the data series and vise versa. 
  The values marked by the red circle should be around 0 but are at approximatley -200.
  <a href="https://i.stack.imgur.com/5c6HT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5c6HT.png" alt="enter image description here"></a>
  Any idea how to fix this. 
  Qt reference doesn't seem to help.</p>