So I need to make a line chart, the columns will be split to 9 objectives, and the rows a 1-6 scale. USers are asked to rank themselves between 1 and 6 at the start and end of the course and I wish to show a line for each objective to signify the travel from point A. (start) to point B (end)Somehting like this:
I just can;t seem to make it work! Any suggestions?
In my opinion there are at least three possible approaches to this but each one has it drawbacks:-
(1) Just plot each Line separately as a Line graph and move it to a separate sheet (right-click and select Move Graph). Then you can put the graphs next to each other. The down-side is that it is rather fiddly and you may not want them to appear as separate graphs.
(2) Do the first graph as a Scatter using 1 and 2 as the x-coordinates and your first 2 points as the y-coordinates. Then do the next graph with x-coordinates 2 and 3 and use copy and paste to move it onto the same axes as the first graph (click on the line joining the points and use Ctrl-C and Ctlr-V to copy it onto the first graph). The downside is that each line copied in this way will come out in a different colour and once again it is fiddly to change it.
(3) Do the whole thing as one Scatter graph. You need to re-format the data as below to get some suitable coordinates. To get the break between the lines you need a genuine empty cell (not "" produced by a formula) so I suggest you copy the coordinates in pairs (e.g. F2:G3 to F5:G6) and leave every third pair of cells in the column empty. Then select the whole range F2:G27 and insert a Scatter with straight lines joining the points. Fix the X-axis range from 1 to 9.9 and the y-axis range from 1 to 6 and add axis labels and title as required. The downside of using a Scatter like this is that you only have numbers rather than text along the X-axis but it shouldn't matter in your case where you just need an objective number at each tick mark.
In F2:-
=INT((ROWS(F$1:F1)+2)/3)
In F3:-
=F2+0.9
In G2:-
=IFERROR(INDEX($B$2:$C$10,INT((ROWS(G$1:G1)+1)/3),MOD(ROWS(G$1:G1),3)),"")
Related
On a data/line plot inside Excel, I'd like to color my data points depending on a value inside the table on the same row as the data value, however from a different column.
It's best explained with a picture:
It's essentially a line chart type with the lines removed, and the data points set to bullet type and given an increased radius for visibility. The x-axis denotes the calendar date as dd.mm, and the y-axis contains the values.
Now the Excel table also contains a row called "Time of Day", which can be mo(rning), mi(dday), ev(ening).
Can something like this be done with a line chart, or do I need to use a different type of chart, or is this generally not possible in Excel (which I doubt)?
Excel in use is: Microsoft Excel for Mac, Version 16.51 (21071101).
Here's a way to achieve this:
What I've done is:
Added three columns for the times of day (columns B, C and D). These can be hidden.
Added this formula in B2: =IF($E2=B$1,$F2,NA()) which should then be dragged to cover the next two columns and then down to cover every day.
Selected A1:D11 (it'll be more than 11 on your version)
Went to Insert > Chart > Insert Line or Area Chart > Line With Markers
At this point you have a line chart with three series (mo, mi, ev). The lines can be removed, which just leaves the markers. You can format each series separately, with different colours, shapes, sizes, etc.
As a special bonus, this automatically gives you a legend that explains the colours.
Below is an Excel Chart for the data shown in column A (x-coordinates--dates) and column B (y-coordinates--test results). There's no problem with the column B data. But note that the horizontal axis shows quite a few more dates than are contained in column A.
Is there any way to have only the actual x-coordinates shown on the horizontal axis with a scale that matches those values?
I kind of get it. Excel deliberately scales the horizontal axis to match as best it can the data in column A. But I don't want that. Beneath each "corner" point of the graph, I'd like to see the date that is associated with the test result in column B.
In other words, there is clearly a point with y-coordinate 154.5. I'd like to see 2/13/2018 directly below that point since that is the data in row 5. Note that the x-axis contains the "correct" date for the first plotted point: (2/9/2017, 70). But for the point with y-coordinate 80, it looks as if that test result occurred on 6/9/2017 rather than 6/16/2018.
So I'd like the graph to appear as shown in the second image, which likely would be impossible because of the "crowding" of x-coordinate values at the right-hand end, but just displaying whichever of the three dates would fit would be good enough, as would just showing one of the two dates in other "crowded" areas. That is to say that something like the third image would be fine.
I suppose I could write VBA code to make it happen, but I'd prefer that Excel do it.
(What crosses my mind is, "Are exact dates really this important?" And the jury is still out on this point. There are arguments both ways. I guess a hung jury goes to the judge, Excel.)
By inserting the points to be plotted into two arrays, datesArr and scaledArr, and putting those values into columns A and B (see worksheet) and in code saying ...
Set ch = ActiveChart
Set s = ch.SeriesCollection
s(1).Values = scaledArray
s(1).XValues = datesArr
... I got exactly what I wanted. Now granted that's not exactly built-in, but we're programmers, yes? And this was downright easy. Well, once I learned a few tricks, especially being able to set angle of dates to 45 degrees.
You need to plot two sets of data, the actual values, and a set of zeros, then smoke and mirrors make it work.
Data below left, make a line chart (top left chart). Add data labels to the second series; I colored the labels orange to match the points, for clarity in this description. Default labels show Y values, which are all zero (top right). Format the data labels to show category values (i.e., dates), below the points, rotated upwards (bottom left). Format format format (bottom right). Axis labels: none. Format second series with medium gray lines and medium gray cross markers. Drag bottom of plot area upwards to make room for the date labels. Hide legend.
My problem is as follows:
The user inputs two numbers between 2 and 25, these numbers are used to create a grid. Every point on the grid has (x,y) coordinates. Based on the amount of points the user chose, my excel sheet is filled up with up to 25x25 (x,y) coordinates.
Example: A 6x7 grid is chosen by the user, the table is filled with 42 (x,y) coordinates and all other values in the table are set to "".
Now I want to use a scatterplot with lines connecting each array to plot the data.
Problem 1: If I only select the 6x7 part of the table that has values in it and create the scatterplot the result is correct. Until the user specifies a different grid, for example 8x9, then the graph is obviously missing two rows and two columns of input data.
Problem 2: If I select the entire 25x25 part of the table, including all the "" values, the graph axes get messed up. The y-axis works properly, but the x-axis shows sequential values (0-7) instead of the x-coordinates.
Problem 3: If I replace all the "" values in the table to 0 or NaN and plot the entire table the axes are correct, but the lines between the scatter data get messed up.
Question:
Is there a way to automatically change the input data for the plot, or is there a way to correctly display the values on the x-axis if I select all the data?
Not sure this will work in your case, but it's worth a try, especially since no one's addressed your post in 3+ hours. I've had success with this approach: 1) charting the largest data set, 2) copying the resulting chart, and 3) trimming the data it draws from to produce all smaller data sets.
To get this to work takes a lot of thought in laying out that largest data set so that all the other plots follow as needed. To illustrate, I've somewhat mimicked your data and in the animated gif I show largest data set, plus 2 others produced by copying it. Then I demonstrate how to make the second one, including the rescaling required to make all plots scaled equally. Notice that I've arranged things so that only one set of x-values feeds all the series. If you can do this, it makes working with the Excel's interface much easier.
After wrestling with it all night I came to the following solution:
Instead of setting all the empty cells to "" or zero the cells should be be set to #N/A (not available). The graph properly ignores the #N/A cells exactly like I want it to and updates when values are entered into them.
I am trying to plot a family of curves in space using gnuplot.
I am trying to do it with for-loops. The data are in 4 columns, and every 20 rows, a new plot starts, e.g., if I do a plot using the 3 and 4 columns, on the row 21, the index in the third column starts again, and the number on the second column increases by one. This pattern repeats, and every 320 rows, the index on the first column increases by one, and all the pattern repeats itself again.
The index in the first column goes from 2.0 to 3.8 whereas the index on the second column goes from 75 to 90.
In my code I tried to set the range limits from 1.8 to 4.2 for one axis, and from 0 to 100 for the second axis.
I wrote the following code
a=0 # this variable indicates how many rows to skip
do for [j=20:38:1]{ # loop for the first column
do for [i=75:90:1]{ # loop for the second column #
splot [1.8:4.2][1:101] "dataforgnuplot" every ::a::a+19 u 1:3:4
w lines title sprintf("%3.2f %3.2f",j/10.0, i);
a=a+20;
}
}
and it generates one curve at a time, but the previous one disappears, I had a look at multiplot, and also was trying with replot, but, I still haven't found how to do that.
You should approach this differently. If you put blank lines in your input file in the right places, and plot the whole file, gnuplot will know exactly when to stop drawing one curve and start the next one.
From the gnuplot documentation:
Single blank records designate discontinuities in a plot; no line will join points separated by a blank records (if they are plotted with a line style).
Two blank records in a row indicate a break between separate data sets. See index (p. 79).
The difference between the two cases is that separate curves which are part of the same data set (one blank line) will be plotted in the same color and with a single entry in the legend. Different data sets will have different colors and separate labels.
It should be easy to change the program which outputs this data if you have control over it, to add the extra blank lines. If you don't control it, a one-or-two-line script should be able to insert the blank lines, either based on the line counts you gave, or by checking the first and second data records.
I know how to draw a line with scatter plot options where X is the independent and Y the dependent variable.
In the scatter plot of that data I need to add another line: X=2. I have the following data:
But how to draw a line X=1 ?
Maybe you want something like this:
I hear that charting is more different than many other aspects of Excel between versions and that perhaps my version (Excel 2007) is one of the least ‘friendly’ hence some of the reason for “not very easy” but the principle is as #Bill the Lizard has described. In view of some weird behaviour with (my?) Excel 2007 however I recommend being careful about the sequence in which the lines are drawn.
First I suggest getting your chart right for all aspects but the green line. Then add another series with X values of 1 and 1 and Y=2 values of 10 and -2 (or whatever the limits are of your chosen y-axis as displayed). Select and copy that array (four cells) select your chart and Paste Special…, and Add cells as New Series, Columns, Categories (X Values) in First Column, OK.
This should add a vertical line of the same chart type as the existing (ie XY (Scatter) Scatter with Straight Lines and Markers). The colour can be changed, by selecting that series (click on it and Format Data Series…, Line Color etc) and presumably you would want the markers removed. It was these that for me at first refused to disappear to order – but persistence paid off. Click on either of the data points, and under Marker Options choose none for Marker Type. If necessary, repeat for the other data point – and keep repeating if required!
Also, I selected what was showing as Series3 (text) in the legend and deleted that.
Forgot to mention that for anything to do with Excel charts Jon Peltier is the ultimate authority (eg) and that an alternative approach is to use an error bar and a secondary vertical axis.