I am making a data logger for a couple of Arduino sensors in Qt. The problem is that I want to log the data in 3 different graphs, each of one having one specific scale, and then I'll choose what graph I will show (just one of the 3 graphs will be displayed at one time).
I tried something like this:
QCPGraph *sensorXGraph = ui->graph->addGraph();
QCPGraph *sensorYGraph = ui->graph->addGraph();
sensorXGraph->setVisible(false);
sensorYGraph->setVisible(false);
And then, in a slot call from a RadioButton clicked event I did:
sensorXGraph->setVisible(true);
sensorYGraph->setVisible(false);
And the inverse for another RadioButton. But the graph seems to keep the axis of the last graph created. So, if I try to see the sensorXGraph, the data will change accordingly but y axis range will be the one of the sensorYGraph.
I also tried to make a single QCPAxis for each graph, but it started to be a mess because I had to make QCPAxisRect for each graph as well and the result was worse than the first trial.
How do I achieve to change from one graph to another properly?
Thank you in advance.
You can call clearGraphs() on your QCustomPlot and then add whatever graphs you want to display by calling addGraph() and then call replot() on your QCustomPlot. So it would be something like this:
ui->graph->clearGraphs();
ui->graph->addGraph();
// Do whatever you need to do to edit your graph.
ui->graph->replot();
Since you are using a radio button I think that it would be easier to draw one graph and add the necessary data and labels based on whatever radio button has been selected. Hopefully that helps!
Related
I'm trying to plotting multiple lines in one single graph. I've combined two of them using dual axis, but I don't know how should I add another.
Thank you in advance for any help.
Since you have mentioned that you want to show multiple measures in one viz it means that one axis is sufficient for all these measures. Therefore, Instead of creating dual axis chart, do it like this-
Step-1 Build line chart with one measure.
Step-2 Drop another measure on the axis directly instead of rows/column shelf where you'll see a double bar icon like the screenshot.
step-3 Drop additional mesaures either in similar ways or onto measure values pane created automatically. See a demonstration screenshot below on sample superstore
When a graph is very wide I want to show the y-axis values also on the right side of the graph so it becomes easier to read the corresponding values of the lines.
I know how to duplicate the left axis to the right. And when the graph is created I use ActYscl to set the range of scale nr 0 (left) to scale nr 1 (right). This works when the graph is created and also the zoom and pan function work on both y-scales. However, when I use the Autoscale function of the Graph Pallet, only the initial axis is scaled (probably because the graph data are only linked to the original axis).
Is there a way to make the autoscale function work for both y-axis at the same time?
Charts and graphs have an Autoscale Range Change event. Use an event structure to catch this event and update the range of the duplicate scale to match the first one:
I've used a chart for this example as it's simpler, but it should work the same for a graph. Of course you need a way of telling the event loop when to exit; I've used the Value Changed event of the stop button. If your application uses an event-driven structure anyway, you should just be able to add the autoscale event to your existing event loop.
Concerning the superb iplots package in R:
By default, pressing CTRL and moving the mouse over a point in a scatter plot shows the x and y values of this point. How can I extend this to also show other attributes, which are not part of the plot, as shown here (see Mondrian screenshot) and as asked here, too?
In Mondrian, this works perfectly well by selecting any attributes within the data overview window and then pressing CTRL + SHIFT on a data point in a scatter plot for example. In iPlots, there is no way to select the attributes like this. I thought iplot.setExtendedQuery() is the key. However, there are no examples on how to use the query string.
Selecting a point plus printing the attributes using sth in the veins of mydata[iset.selected(), ] can't be the only way to go...
I am using the standalone LocusZoom software,but I am having two problems:
I have to create a plot showing only position on the x-axis (not showing the genes). If I just use showGenes=FALSE with nothing else the genes still appear, but if I use rfrows=0 then the genes are not shown, but the problem is that also the x-axis label with the positions disappears. Is there a way to only show the position label? It looks like the only way to do this is to modify the original script...
Is there a way to use several plots created using LocusZoom in an R script to position many plots into one unique figure? (output is a pdf for now) There is an option listed in the LocusZoom webpage (http://genome.sph.umich.edu/wiki/LocusZoom_Standalone) called "prelude" but I cannot get more info on how to use it.
If you have any suggestions for either of these two issues it would be very helpful! Thanks!!
I have a real-time line chart. For that I use TimeSeries. Now I get new values every second. But I don’t want to get a x-axis line every second. I like to get one every ten seconds.
So maybe, first it would be important to know where the x-axis lines were painted. Is it xymultipleseriesdataset.addSereies(timeSeries)? So maybe I can create a loop that add every 10 second a new title for the x-Axis... or am I totally wrong?
If I am right, you are asking for a way to control which labels are shown on the x-axis.
To do that, you may use the XYMultipleSeriesRenderer.addXTextLabel(timeInMillis, "requiredlabel").
This will cause the automatic generation of labels to stop and you can then have complete control on which labels are shown and which are not.
Edit:
Seems like I was wrong about automatic generation of labels stopping.
Use the method XYMultipleSeriesRenderer.setXLabels(0) to stop the generation of labels. This method is used to set how many labels should be generated for the x axis. Passing 0 should stop automatic labels to stop altogether.