I'm beginner and try to use QCustopPlot.
I want to draw a real time chart.
I use this example code.
but I have so many questions:
1) how can I fixed yAxis to a specific int number (0 to 50)
2) how can I fixed xAxis? I mean I want to have a chart that in passing time, the plot moves. (not the xAxis or yAxis)
sory for my bad language.
It looks like these three links should help.
void QCPAxis::setRange ( double lower, double upper )
http://www.qcustomplot.com/documentation/classQCPAxis.html#a57d6ee9e9009fe88cb19db476ec70bca
void QCPAxis::moveRange ( double diff)
http://www.qcustomplot.com/documentation/classQCPAxis.html#a18f3a68f2b691af1fd34b6593c886630
QCPAxis Class Reference.
Manages a single axis inside a
QCustomPlot.
http://www.qcustomplot.com/documentation/classQCPAxis.html#details
Very similar functions exist in QWT, also.
the cpuplot example in QWT shows a scrolling realtime example. There isn't an online link that I can find for the examples, so you should download it and open the examples after you build it.
Hope that helps.
Related
I have an XY scatter plot of many points which define filament like structures (imagine looking at a pile of sticks laying on the ground, that's what these plots look like). I am using Locator to identify a start and end of each filament. The end result I get is a table of line segments defined by two points in XY.
A simplified base version of my code runs like this:
n=1
NumberOfFilaments=5
Xdata=rnorm(1000,mean=500,sd=100)
Ydata=rnorm(1000,mean=500,sd=100)
clicks.table=c()
while (n<=NumberOfFilaments) {
plot (Xdata,Ydata)
clicks = locator(2)
A = c(clicks$x[1],clicks$y[1])
B = c(clicks$x[2],clicks$y[2])
clickpoints = c(A,B)
clicks.table = rbind(clicks.table,clickpoints)
n=n+1
}
Some of my data sets have gotten quite large in regard to the total width of the data in X & Y in comparison to the length of the filaments I am trying to click on. This makes it hard for me to accurately click on the start and end of the filaments. What I would like to be able to do is zoom in on the plot to view an individual filament, click two points then zoom out to view the whole pile again. I typically use R studio if that matters. Thank you in advance.
I'm using pyqtgraph for a live view of a camera acquisition program. Most of the times my images are composed of a lot of background noise and a signal of just a few pixels with higher intensity. For that reason, the part of the HistogramLUTItem that corresponds to the actual signal looks like a thin line and the noise is big next to it. Being able to plot the logarithm of the data would make the data to stand up more.
Is this possible?
I'm currently creating the histogram this way:
imagewidget = pg.GraphicsLayoutWidget()
self.p1 = imagewidget.addPlot()
self.img = pg.ImageItem()
self.p1.addItem(self.img)
self.p1.getViewBox().setAspectLocked(True)
self.hist = pg.HistogramLUTItem()
self.hist.setImageItem(self.img)
self.hist.autoHistogramRange = False
imagewidget.addItem(self.hist)
Doing self.hist.axis.setLogMode(True) didn't work as it affected the x-axis of the histogram instead of the y-axis.
And finally, I would also like to be able to limit the accesible range in the x-axis of the histogram. How can this be done?
Cheers!
Ok, I finally figured out. In case someone wonders, I solved it by adding these two lines:
self.hist.plot.setLogMode(False, True)
self.hist.vb.setLimits(yMin=0, yMax=16000)
I am trying to get those cool network graphs I saw on the cubism.js presentation where the RX was upside down on top and the tx was normal below.
The fact is that the only way I seem to get the chart drawing upside down is doing metric.multiply(-1) but then the values are negative so its not exactly ideal.
Any hint?
In the absence of a nice way to do this, you can replace the horizon chart formatter with one that just emits absolute values. You can do something similar with comparison charts too.
Something like this works :
var horizon = cubism.context().horizon();
var existingFormatter = horizon.format(); // Obtain the format function
var absoluteFormatter = function(value) {
return existingFormatter(Math.abs(value));
};
horizon.format(absoluteFormatter);
This will have the effect of still rendering the charts as a "negative" but will allow you to render your values as desired.
Obviously, you can adopt according to your needs.
I have certain x and y coordinates for the position of an animal for a certain time t-max. I am using the code in R:
for (t in 1:tmax) {
plot(x[1:t],y[1:t]);
Sys.sleep(0.1);
}
to see how the animal is moving with time. So this shows me the path from each value of x to the subsequent value, till tmax. So now i have to present my findings in a Powerpoint presentation. so i was wondering if there is a method to insert this graph in a slide so that when i click a button, the graph is plotted and everybody can understand how the animal is moving.
Have a look on the Animation-Package on Cran:
http://cran.r-project.org/web/packages/animation/index.html
The animations package is cool, but i found it hard to learn. Instead of sleeping after each point is plotted, you could save the graph, and then use a video editor to merge the graphs into a movie clip. Windows movie maker will do this for you.
I'm not a big fan of animation, and in this case it doesn't seem useful. Why not just plot the graph, or if the path is seriously tangled, plot with a rainbow colormap applied to the line so you can easily follow from start to finish? See plotrix::color.scale.lines
When making a line chart, Lets say its for business sales for different depts and horizontally is days and vertically is dollars. When you hover over a line it tells a dataTip tells you the sales for that dept. on that day. I want it to show all the depts at the same time, so say you hover over day 3, I want the dataTips for all depts on day 3 to display so you can compare the values for all the sales on the same day. I set the mouseSensitivity for the dataTips to display all the lines at once but I end up getting day 2 for one dept and day 3 for another which is not wanted. This is actually posted as a bug and explained better here: http://bugs.adobe.com/jira/browse/FLEXDMV-1853
I am wondering if anyone can come up with a work-around for this?
Thanks!
I ran into a similar problem to this recently and came up with a solution that also applies to your problem. I had a step LineChart and wanted to display a data tip when the user hovered anywhere on the line instead of just at defined data points.
You can read about the solution I wrote for that problem here: Flex: Customizing data tip location and behavior in a LineChart
You'll have to modify my solution slightly to fit your problem:
On line 47 you can remove the Math.abs(last.y - mouseLoc.y) < 50 check. This constrains the data tips to lines that are within 50 pixels vertically of the mouse.
I'm assuming that you're using the default segment line chart which just draws lines directly between data points. You'll need to modify the code that calculates the line value at a given x-coordinate to work with that chart type. I already find the closest data point to the left of the mouse with lines 33-41 and store it in last. Just get the next data point (which will be the one closest to the right of the mouse) and use something like this to get the value at the mouse:
var slope:Number = (nextPoint.y - last.y) / (nextPoint.x - last.x);
var lineYAtMouse:Number = (slope * (last.x - mouseLoc.x)) + last.y;
var lineValue:Array = line.localToData(new Point(mouseLoc.x, lineYAtMouse));
Then replace lines 69 through 72 with:
hitPoint.x = mouseLoc.x;
hitPoint.y = lineYAtMouse;
hitPoint.xValue = lineValue[0];
hitPoint.yValue = lineValue[1];
I haven't tested these modifications so there could be a bug or 2 but the general idea is there. I hope maybe this is still useful to someone. This question is getting pretty old. :)
Not an answer, but a poor alternative:
You could create your own DataTip renderer that [ahem] mapped the location of every point and drew the tip for each one there.
Basically, you would be duplicating a lot of the code inside the charting classes.
I have the same problem but working on column charts. Was thinking that I could enable the vertical gridLines using backgroundElements and then add a chart event listener for mouse over (which fires when mouse passes over a vertical gridline). Using the localX value, i could compare it to the closest datapoint, maybe.
Brian