I need more general XY point to point plotting than XY scatter in

S

spazminator

I want to connect two sets of XY points (in four columns) with line segments,
and show the entire set on one 2D plot. XY scatterplot is frustrating because
it is almost there, but not. You can create a grid of points but not connect
the dots. You can't paste data into the plot either -- it assumes you want to
use the same X as the first set of points. Aaaaaaarg.
 
M

MrShorty

Can you be more specific as to what you need? I've never had any
trouble plotting an XY plot and having the data points connected by
straight lines. Normally either select the "connected by lines" option
when the chart is created, or select the data series Format->selected
series->patterns tab->select the desired line style to connect the
points.

I almost never use the paste command to add a data series to an
XYchart. I will either use the paste special command (which allows me
to specify that I'm using new or different X data) or use the
Chart->Source data->Series tab to add a data series.

If that doesn't help, then post again with more details about the
problem you are having.
 
S

spazminator

Here is some sample data (csv):

name,X1,Y1,X2,Y2
A,0,0,2,0
B,0,1,2,1
C,0,2,2,2
D,0,3,2,3

I want to show line segments only between A-X1-Y1 and A-X2-Y2; B-X1-Y1 and
B-X2-Y2 etc, NOT between A-X2-Y2 and B-X1-Y1 or B-X2-Y2 and C-X1-Y1 etc. It
would be cool if the A, B, C, D labels could be visible on the graph, and
even better if I could then paste like data onto the chart, even using paste
special and have it conform, but I've tried many times without success. It
always messes up the new source data with wrong assumptions. Try it.
 
M

MrShorty

Others may have better ideas, but it seems to me your data aren't lai
out in a format conducive to what you want. I was able (using th
"source data" dialog I mentioned above) to get a plot that looks lik
what you describe. I had to select each individual point separated b
commas within a given series. The final series definition looked lik
=SERIES(Sheet1!R5C1,(Sheet1!R5C2,Sheet1!R5C4),(Sheet1!R5C3,Sheet1!R5C5),4)
That, of course, isn't conducive to readily adding points to
series, or adding series to the chart. Can be done, but not readily.

If you lay your data out differently, it would be easier. Try a la
out where the X data are in a column and the corresponding Y data ar
in the adjacent column. Something like:

name A A B B C C D D (names doubled to emphasize column relationship)
axis X Y X Y X Y X Y
pt1 0 0 0 1 0 2 0 3
pt2 2 0 2 1 2 2 2 3

Then it's easy to add data points (simply add rows) and data serie
(simply add pairs of columns going across and paste special) to you
chart
 
B

B. R.Ramachandran

Hi,

Rearrange the data as,

name, X, Y
A, 0, 0
2, 0
B, 0, 1
2, 1
C, 0, 2
2, 2
D, 0, 3
3, 3

and plot Y vs X for each group as a separate series on an XY-plot. Format
each data-series to connect the two points in it.

OR

Rearrange the data as above. Create ONE plot with the entire data series.
Rightclick on any data-point --> "Format Data Series" --> click on
"X-ErrorBars" Tab --> under "Display" check "Minus", check "Percentage" and
enter "100" --> "OK"

OR

Rearrange the data as above, but insert a third X,Y pair (which would be
idential to the first X,Y-pair) in each group.

name, X, Y
A, 0, 0
2, 0
0, 0
B, 0, 1
2, 1
0, 1
C, 0, 2
2, 2
0, 2
D, 0, 3
3, 3
0, 3

Create ONE X,Y-scatter plot for the entire data, and format the series to
connect the data-points. The cross connections such as A-X3-Y3 and B-X1-Y1,
B-X3-y3 and C-X1-Y1, ... will coincide with the Y axis (and hence wouldn't be
a distraction, of course, this would work only if the X-value of the first
point in each group is zero!).

I am sorry for not being able to suggest a more elegant solution.

Regards,
B. R. Ramachandran
 
S

spazminator

Exactly... can be done but not readily... reformat your data...
I think MS with just a little thought could add a new chart type that would
be a lot more conducive to "pen plotting". Like allowing a pen-up/pen-down
column or something. Also it seems to me that the default of assuming the X
column in an XY scatter plot is going to be the same for each new series --
is just busted.

I hate that charting in general is so geared for accounting and
presentations and so limited for engineering or science uses.
Why isn't there a 3D XYZ scatterplot chart type for instance?
Why does one have to buy/load/install extensions for mathematical analysis?

I will try your point-per-line idea though. It looks like the best solution
so far. It's just that there are a lot of points and I need them in the
current format for other reasons on the sheet. Looks like I'll be adding a
new worksheet for the chart.

Thanks for trying.
 
S

spazminator

Hmmmm. The Error-Bars thing might have promise -- but I didn't think it was
available in XY plots. I'll try.

No, the real data doesn't start every line on the Y axis. Just my contrived
data.
Thanks for looking.
 
B

B. R.Ramachandran

Hi,

The Error-Bars approach (Method 2 in my previous reply) would work only if
the lines are horizontal (zero slope). If it is not the case, you have to
plot each group (two points) as a separate series (Method 1)

If the lines are horizontal, but the lines don't start on the Y-axis, you
have to use a slight modification to Method 2. To avoid confusion, I have
named the groups as P, Q, R, and S. Supposing tthe Group Names are in Column
A, X-values in Column B, and Y- values in Column D, starting at Row 2.
A, B, C
P, 0.5, 0.5
2.5, 0.5
Q, 0.7, 1.2
2.1, 1.2
R, 0.3, 2.1
2.4, 2.1
S, 0.4, 3.0
2.7, 3.0

Create a new column, D, which would contain the X-Error values as follows:

In D2 enter 0, and in D3 enter =B3-B2, and ENTER.
Now select BOTH the cells, D2 and D3, and auto-fill the formulas down Column
D. For the sample data shown above, the outcome would be
A, B, C, D
P, 0.5, 0.5, 0.0
2.5, 0.5, 2.0
Q, 0.7, 1.2, 0.0
2.1, 1.2, 1.4
R, 0.3, 2.1, 0.0
2.4, 2.1, 2.1
S, 0.4, 3.0, 0.0
2.7, 3.0, 2.6

Now create an XY-Scatter Plot with Y vs X, i.e., Column C vs Col B
Right-click on any data-point --> "Format Data Series" --> click on
"X-ErrorBars" Tab --> under "Display" check "Minus", check "Custom", leave
"+" area blank, and for "-" area, enter the range of Column D (D2:D9 for the
sample data) --> "OK"
This would connect each pair of data-points.

Regards,
B. R. Ramachandran
 
S

spazminator

All this because I was so silly as to create a dataset from scratch which
seemed simple, but unfortunately not representative. The lines I want are
neither horizontal nor vertical nor lined up neatly in any way whatsoever. So
error bars won't do.

Nor did Mr. Shorty's solution produce an elegant result. The global picture
here is that XY-Scatter plots are sickeningly single purpose, with no thought
for general use. Who will and create a better solution? Apparently not MS.
I'm back to drawing plots with gp programming languages.
 
J

Jon Peltier

This is a good example of how an appropriate data layout makes impossible
things easy. You say you need the data in this particular layout for another
reason. Well, it's common that data may need different layouts within the
same workbook. One layout is suitable for on-screen viewing, another is
better for printed reports, a third is good for the data source for a pivot
table, and a fourth might be needed as source data for your chart. Maybe you
need five or six if there are alternative ways you want to display a table
or chart.

Back in the days of multiplan or visicalc, you couldn't afford to "waste"
extra rows and columns on alternative depictions of the same data, but now
we have gigabytes of disk space, and at least hundreds of megabytes of ram.
Go for it, add a worksheet, or set aside another range on the same
worksheet. Copy the data, use Paste Special - Links to paste a linked copy,
then drag these cells around into the proper orientation.

Now you can have your pretty table and pretty chart, and since their data
are linked, when the table changes, so will the chart.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
S

spazminator

No, Jon. It's not easy, no matter what format I use. I tried Shorty's point
set per row format and got the same bad results. If you think about it,
there's no difference between data in rows as data in columns. The entry
function still assumes that the first series' X values should be copied into
every subsequent series. The scatterplot function is just broken and should
be fixed and made more general and less specific to single data series
applications. I don't really appreciate your marketspeak "all is great"
comment. It helps not at all. What I would appreciate is a promise to create
a new and better point graphing function.
 
J

Jon Peltier

Well, I don't know where I said "All is great." I merely pointed out that
properly arranging your data makes charting much easier.

As you said, it's not a matter of rows vs. columns. Your data is not rows or
column, it's a single row with alternating X and Y values. This is
particularly inefficient, but Mr Shorty and B R Ramachandran have both
presented better ways to arrange your data.

When specifying a single data range for multiple series, Excel does assume
that the first column (row) contains X values to be used for all series and
subsequent columns (rows) contain Y values for the different series. This is
actually valid behavior for a line or column chart, though not usually what
is intended for XY charts. But in this case you could add series one at a
time, which allows you to specify distinct X and Y ranges for each. Or you
could implement some kind of VBA solution which parses the data range for
you, bypassing the chart wizard. I have posted some examples here:

http://peltiertech.com/Excel/ChartsHowTo/QuickChartVBA.html#xycharts

I also have a preliminary add-in which allows selection of data from a
number of nonstandard arrangements, but it's not ready for general
distribution. If you're interested in doing some testing, email me outside
of the forum, and I'll send the latest version.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
S

spazminator

Jon, THANKS! for the helpful website.

I might have tried writing VBA for the problem, but 1) I don’t have a
license for it, and my work isn’t likely to purchase it; 2) I don’t really
want to go through another language learning cycle just to get XL to do what
it really should do anyway; 3) after this chart is done, I’m off to some
other project and who knows what XL feature I’ll break there.

I don't think I've EVER had a use for single-X multiple-Y data on an XY
chart. Why can't the chart wizard be wizen'd up?

How hard would it be to create a chart type with a pen-up pen-down (T-F
column) feature?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top