Working in jupyter, trying to plot time series - jupyter

I just want to use any simple seaborn or matplot plot to visualize my data set as a lineplot. Please help. I cant seem to figure out how to plot these values i keep getting all types of errors.
My data set consists of 4 columns, the first is date which I want to plot on my x axis and the rest are numeric values of gold, oil and the dollar that I want to plot.
I have my dates set to datetime value and the rest set to float64, I am trying to plot the fluctuations of oil, gold and the dollar over time to look at any possible correlation. Sorry for any obvious mistakes I am not an expert.
Doing This gives me only one plotted value and the Date values on x axis is incorrect
plt.xlabel('Date')
plt.ylabel('Values')
plt.title('Historical Data')
df['Price_Gold'].plot()
So basically im running into trouble when trying to plot multiple values against time.

df.plot(x='Date', y=['Col1', 'Col2'])
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html

Related

How to generate 3d scatter plot with different colours for labels in MATLAB?

I have used TSNE in MATLAB for dimensionality reduction of a large data. I have been able to generate the Scatter Plot for TSNE in 2 dimensions which shows the labels of the cluster in different colors for each label, but, I am unable to do so in 3D. Referring to https://uk.mathworks.com/help/stats/tsne.html, I used the following syntax:-
Where, merged_data_all is a 21392x1974 table with the last column named FunctionalGroup containing different labels (similar to the Fisheriris species labels in the Mathworks example on tsne). Y2 is the 3 dimensional variable which I have been successfully able to generate of dimensions 21392 x 3 double.
figure
v = double(categorical(merged_data_all.FunctionalGroup));
c = full(sparse(1:numel(v),v,ones(size(v)),numel(v),3));
scatter3(Y2(:,1),Y2(:,2),Y2(:,3),15,c,'filled')
title('3-D Embedding')
view(-50,8)
When I use this code, I get the error "Error using sparse- Index exceeds array bounds". I even tried to use a modified version of the code and doing something like this
scatter3(Y(:,1), Y(:,2),Y(:,3),merged_data_all.FunctionalGroup)
In case of this, I get the error "Error using scatter3- Input arguments must be numeric, datetime or categorical". I am quite confused as to how I can plot a 3d scatter plot, with 14 different colors (for the 14 types of different labels I have in my FunctionalGroup column of merged_data_all). Any help in this regard would be highly appreciated. Thanks

Matlab timeseries plot error

I am having an issue when trying to plot these two timeseries against each other:
subplot(2,2,3),plot(wrm,Te);title('Speed-Torque curve');
xlabel('wrm [rad/s]');ylabel('Te[Nm]')
axis([-5 10 20 200]);
grid;
It comes up with the error of
Error using plot
A numeric or double convertible argument is expected
Error in timeseries/plot (line 163)
p = plot(ax,Time,Data,varargin{:});
I have tried changing the "to workspace" variables in simulink from 1x1 double timeseries to arrays and that seems to allow me to plot, but the plot for just Te become incorrect.
All other plots I create, I am unable to follow the format of plot(time,yvariable) as it gives the same error so I have been just using plot(yvariable) which has worked up until now.
Any help would be appreciated. Thanks!
From your question I don't understand exactly what you are trying to do. If you are trying to plot the data members of the two timeseries objects against each other, use
plot(wrm.Data, Te.Data);
If you are plotting the data members, you of course need to make sure these vectors are the same length. If they are not, you could use something like
Te2 = resample(Te2, wrm.Time);
If you want to plot both against time instead, use
plot(wrm); hold on; plot(Te);
Or, as I like to do:
wrm.plot(); hold on; Te.plot();

Time Plot on X-axis in Matlab

sorry if this question has been asked before.
I'm collecting data from a sensor which gives me a reading every millisecond which gives 864000 readings per 24 hours.
When I plot this I can only get it to show sample number, what I'm looking for is a plot that has every hour shown, for example 13:00:00:00 for 1pm, so every 36000 data points, and when I zoom in between data points I want it to show the exact time at that point, such as 13:25:30:60 etc.
I assume the best way to do this is to create another variable with just time on it and plot my variables against this? Any other ideas would be much appreciated
You can have two arrays:
One containing your samples, say y.
And another one containing datetimes corresponding to each sample, say x.
Then you can use:
plot(x,y)

How to create a vertical scatter graph using range specific abscissas using Sigmaplot

I am currently working on a project in which I will be creating a vertical scatter plot using on average 6 points of y-axis data using Sigmaplot. The units of the graph are depth of snow in cm vs time. However the data I have collected is gathered over a range of days (i.e. 173-176) and I am having trouble applying my data sets to their respective ranged abscissa. I've noticed inputting the data in this manner finds the difference in the abscissa (i.e. 173-176 would correspond to 3) rather than interpreting the data as a range. Can anyone help me find a way in which to input abscissa not as singular values but rather ranges of those values using Sigmaplot?
Leaving the abscissa ranges in tact, plot all of the data. Sigmaplot does not want sort these data and rather places them in their respective chronological order. I did not find a way to make the width of the points as wide as the abscissa.

matlab convert milliseconds to date format and plot as x-axis

I am new to matlab. What I am trying to do is to plot the data I recorded from the phone on matlab. The data is looks like this {timestamp, value}.
The timestamp is recorded in millionseconds by calling the Java function System.currentTimeMillis(). Therefore I have two questions actually to plot it on matlab.
How can I transform the timestamp from milliseconds to date format on matlab?
How can I plot the data on matlab, where Y-axis is the value, and X-axis is the date? The graph should look like discrete dots.
Thanks a lot.
To create plots with dates / times on one axis, plot your data, then relabel the axis using datetick
plot(datenum('1-jan-2000'):datenum('10-jan-2000'),[1:10])
datetick('x','dd-mm')