Excel scatter plot x axis displays only sequential numbers but not real data selected for x axis - excel-charts

I have an excel scatter plot with 5 different data series on single chart. First 4 series are working well. When I want to add a new series with similar x-axis data (0.0, 0.4, 0.9 .. ) the plot is displayed with x-axis values as 1,2,3 but not as the data specified.
Changing the chart types did not help. Not sure how can I get the x-axis as data but not as sequential numbers. Any help is appreciated. Thanks.
Added the screenshot of chart and its xaxis data. The values are in number format only just as data for other series. Everytime I am adding a new series on to this, its starting with one number later.... (1,2,3...) next series x axis at (2,3,4....) but not with real x values as selected.

Solved it my slef... The problem is X-axis range is for 18 cells and all the cells had formula with IF condition... When I removed the IF condition, x-axis worked well as numbers
The IF condition I used was "=IF(A10<>"",B10=A10-A4,""), for some reason excel chart considered this as some text and populated the x axis as 1,2,3 but not as the values specified.

Related

How do I graph variables that represent different timepoints?

I am trying to make a line graph, that will plot data over 4x time points for different conditions. Right now, I have the conditions as one variable, but the values for each time point are each in their own variable column.
I can't figure out how to best graph it such that the y-axis shows each condition, and the x-axis shows the "score" over each time point.
How do I graph variables that represent different time points?

Forecast plot with x axis labels as date

I have a dataset like revenue and date.
I used arima to plot the data.
ts_data = ts(dataset$Revenue,frequency = 7)
arima.ts = auto.arima(ts_data)
pred = forecast(arima.ts,h=30)
plot(pred,xaxt="n")
When I plot the data, it produces plot like below.
My expectations are below,
I need to display values in Million for predicted values like 13.1M.
I need to show x-axis as date instead of data points numbers.
I tried several links but couldn't crack it. Below are the experiments I made,
Tried with start date and end date in ts_data that also doesnt work.My start date is "2019-09-27" and end date is "2020-07-02"
tried wit axis_date in plot function that also doesnt work.
Please help me to crack the same.
Thanks a lot.
You can specify axis tick values and labels with axis()
plot(pred,xaxt="n", yaxt="n") # deactivate x and y axis
yl<-seq(-5000000,15000000,by=5000000) # position of y-axis ticks
axis(2, at=yl, label=paste(yl/1000000, "M")) # 2 = left axis
You can specify the desired position of y axis ticks with at and the labels to be associated with label. In order to obtain the values like 10 M I have used the function paste to join the numbers with the letter M.
You could use the same method also for x-axis, even tough more efficient methods probably exist. Not having the specific data available I have used a generic spacing and labels only to give you the idea. Once you have set the desired position you can generate the sequence of dates associated with it (to generate a sequence of dates see https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/seq.Date)
axis(1, at=seq(1,40,by=1), label=seq(as.Date("2019-09-27"),as.Date("2020-07-02"),by="week")) # 1 = below axis
You can also change the format of the dates displayed with format() for example label=format(vector_of_date, "%Y-%b-%d") to have year-month(in letter)-day.

gnuplot frequency chart timestamp

I have a list of timestamps like shown at the end, and I am trying to make a histogram/frequency chart where the X-axis is the time and the y axis a count of the frequency. I tried doing something like this:
set term dumb
set xdata
set timefmt '%Y-%m-%dT%H:%M:%SZ'
set xrange ["16/04/2018":"14/04/2018"]
plot 'dat'
and in the data file
2018-04-16T14:54:38Z
2018-04-16T13:50:07Z
2018-04-16T12:30:45Z
2018-04-16T11:45:16Z
2018-04-16T11:44:11Z
2018-04-16T10:19:19Z
2018-04-16T10:13:25Z
2018-04-16T00:17:33Z
2018-04-15T23:10:15Z
2018-04-14T22:27:34Z
2018-04-14T23:11:29Z
2018-04-14T22:45:08Z
Result
As you can see the x axis does not represent the time.
EDIT:
With Christoph's fixed code, the result is a plot of the timestamp and row the number.
To better explain the problem I have:
I want to plot the time on the x-axis and I want to plot the number of occurrences of the timestamp on the y-axis and where the timestamps are binned to some value in hours and possibly instead of just drawing bars it would interpolate lines between the peaks of the bars.
I asked for you actual question, because the code you posted doesn't create any plot. Let's see:
If I execute only the code you posted, I get the error all points y value undefined!.
In plot time data on the x axis, you need set xdata time.
Having set that you would get as next error Need full using spec for x time data. Indeed, you must have a using when handling time data, something like
plot 'dat' using 1:0
Then, you would again get the error all points y value undefined!. This time, because the time strings given in set xrange must match those specified with set timefmt.
So, a working version of your code could be:
reset
set xdata time
set timefmt '%Y-%m-%dT%H:%M:%SZ'
set xrange ["2018-04-16":"2018-04-14"]
plot 'dat' using 1:0
This plots time on the xaxis, and the row number on the y-axis.

Creating vectors of equal length from R dataset and plotting them

R has some built in datasets, namely I'm using "lynx" and "LakeHuron" which are of different lengths. "lynx" contains data on annual lynx trappings from 1821-1934, and "LakeHuron" contains annual water level from 1872-1975.
I need to plot LakeHuron data on the y-axis, and lynx data on the x-axis, but only for the years 1875-1934 inclusive. I created two vectors:
lynx.years = c(lynx)
huron.years = c(LakeHuron)
I am stuck at the point of trying to only make a plot for the specified year range. Can someone help me figure out how to plot the data from the two vectors for only the years 1875-1934?
Thank you!
1) The question did not specify what sort of plot was desired so assume it is a two panel plot with one series in each panel with years on the X axis such that only the range of years mentioned is shown. That range of years is the intersection of the years of the two series so:
plot(na.omit(cbind(LakeHuron, lynx)))
Drop the na.omit if you want to plot the entirety of the two series.
2) If what is wanted is to rescale the two series so that their shapes can be shown on a single panel despite vastly different ranges:
ts.plot(scale(na.omit(cbind(LakeHuron, lynx))), col = 1:2)
Again, we could drop the na.omit if the entire series were desired.
3) If what is wanted is to plot one vs. the other then:
plot(unclass(cbind(LakeHuron, lynx)))

Scatterplot axis labels are wrong when plotting dates

I am trying to do a scatter plot of 2 time series data - the data is stored in a data frame. The background of the image is quite grainy and axis labels are not visible when I do:
ggplot(data=dat,aes(x,y))+geom_point()
With below, I get only dark vertical lines:
plot(dat$x,dat$y)
plot() and ggplot() did work after applying as.numeric() to the data(as below) but the axis labels are indices[1,2,...] and not the range of actual values.
plot(as.numeric(dat$x),as.numeric(dat$y))
ggplot(data=dat,aes(as.numeric(x),as.numeric(y)))+geom_point()
I cannot post the images here as I am new to this forum.
By default, the data was getting converted into factor while converting from matrix to data.frame. Below code fixed it.
data.frame(mydata,stringsAsFactors = FALSE)

Resources