Connect all markers within a series on a scatter plot with Time Series - scatter

I have an x/y scatter plot with a time axis. It shows how a given node evolves across my x and y variables over time. I would like to draw a line connecting the markers sequentially according to node number. How can I do this?
I tried playing around with px.line but couldn't get the the same results as with px.scatter.
Info: the data is read from a csv with pandas and has approx 1.6M records (141 nodes x 14K time steps), so performance isn't great...
fig = px.scatter(
df,
x=x,
y=y,
animation_frame="Time",
animation_group="Node",
color=z,
symbol=z,
)

Related

Create plot between two points representing confidence intervals in R

I have a data frame similar to the one created in the example below:
Remove columns with zero values from a dataframe
Is it possible to create a whisker plot connecting these two points in R? I would want the variables on the x-axis and the points on the y-axis.

How to plot overlapping images with matlab

I have several dataset matrices x, y, andz, where z contains values at the positions x,y showing shifted (overlapping) parts of the same picture. x and y are rectangularly centered around different center positions for each dataset.
How can I combine the data in one plot using pcolor or similar? Note that it should be a rectangular plot in the end, but that not all data points are given due to the shift.
I now solved my own question by using the command hold on, which makes it possible to plot several times into the same figure. You just have to run it in between two plot commands.

Suggestions on plotting 3 1-Dimensional variables

I have taken readings on my software defined radio. I have three quantities, frequency, power and error rate. I would like to keep frequency on my x-axis as the latter quantities are measured with respect to frequency. Now I need to plot them on a single curve so that i can see frequency vs power and frequency vs error rate in one shot. I have been looking at matplotlib for quite some time but I see the 3d scatter plots and they seem to not convey the picture i want. So my question is
Is 3d plot useless in my case and I better plot 2 graphs and join the y axes of both graphs together so that I could see both the graphs on top of each other.
Is there a way in python or matlab such that you plot a 3d curve and then if you move the cursor you can see frequency vs power and if you move the cursor the other way you can see frequency vs error rate.
Any other ideas on how i can represent my readings better will be helpful.
When two sets of data share the same dependant variable (x-axis), it is common in scientific literature at least to plot them both in the following manner to save space:
This is preferred to twining the xaxis which can cause confusion for some people. It works especially well if features are to be compared.
This plot was generated using:
import pylab as py
x = py.linspace(0,10,1000)
y = py.sin(x)
z = py.sinc(x)
ax1 = py.subplot(211)
ax1.plot(x,y)
ax1.set_xticklabels([]) # Remove the xticks from the top figure
ax1.set_yticks(ax1.get_yticks()[1:]) # Stops the y axis overlapping
ax2 = py.subplot(212)
ax2.plot(x,z)
py.subplots_adjust(hspace=0.0)
py.show()
I believe there is a better way to remove the xticklabels but I can't remember it at the moment. Be careful not to just py.set_xticks([]) as if you then ask for a grid the top plot has no ticks.

How to automatically calibrate axes in MATLAB?

So I am doing some ECG analysis in MATLAB and so far I have detected the key features as shown in the figure below :
This is the ground truth :
So how do i replot the first figure such that the x axis ranges from 0 to 10 (as shown in the second image)
I want to do this so that I can measure the time duration between the Q(the red cross) and the S (the peak at the minimum marked with a circle).
So essentially I want to
1) Calibrate 3600 samples into 10 seconds
2) Using the above scaling factor, be able to automatically calibrate any number of samples into the relevant seconds.
Thanks.
How did you plot the first figure? If you did not provide any x-axis, as in plot(ecg), the x-tick labels will be enumerated consecutevly in intervals of one. If you do know the corresponding time points t of ecg, you can use plot(t, egg);.
Since you know the sampling rate and assume consistent intervals between each data point, you can generate t yourself by t = 10.0 / 3600 * (0 : length(ecg)-1). This will create an array with length(ecg) elements starting at 0, with 10.0 per 3600 data points, for any length of ecg.
To align the horizontal axis limits more nicely than in the first plot, you can then also use xlim([0, t(end)]).

annotated scatter graph matlab/octave

I have 25 pairs of (x,y) co-ordinates. Each of these pairs corresponds to a country. I want to plot the 25 points on a scatter graph, and have the country name for each point directly next to the point on the scatter graph. I can't figure out how to do this in MATLAB or Octave (I have both MATLAB and Octave and don't mind which I use, which is why I'm asking about both).
Let's say I put the (x,y) co-ordinates and corresponding country labels in a matrix of 25 rows and 3 columns, with the labels in the first column. Does anyone know the command I can use for the desired graph?
Strings don't play well with matrices, so I'm adjusting your storage format slightly. Here's the test data: a 25x2 matrix of coordinates, and a 25x1 cell array of strings.
p = rand(25,2);
names = repmat({'name'}, 25, 1)
You'll have to play with the offsets slightly, but here's the idea:
scatter(p(:,1), p(:,2))
%# Compute some offsets for the lower-left of the text box, based
%# on overall size of the plot
offset_x = diff(xlim) * .01;
offset_y = diff(ylim) * .01;
text(p(:,1)+offset_x, p(:,2)+offset_y, names)