So far I've created multi-line x-y plots but can't see how to make multi-line
scatter plots, ie without same x values. Am I missing something or is this a
feature on its way? So instead of ('', x, y1,y2,y3,...) data I want to plot
Multi-line scatter ('points') plots are basically the same as multi-line line
plots. But if you want to have independent X values for each Y and keep each
series separate (if I understand what you are trying to do), you have to play
around a little with the data array. If you have 2 series, then for seriesA,
your rows will be: array('', x1, y1, '') and for seriesB your rows will be
array('', x1, '', y1). All these rows are combined into 1 data array. Remember
that the column for Y determines its color. Here is an example with 3 series:
<?php# Multi-series scatter plot?require_once'phplot.php';$data=array(# Series "A":array('',1,1,'',''),array('',2,3,'',''),array('',3,6,'',''),# Series "B":array('',0,'',5,''),array('',2,'',4,''),array('',4,'',3,''),# Series "C":array('',1,'','',8),array('',3,'','',4),array('',5,'','',2),);$p=newPHPlot();$p->SetDataType('data-data');$p->SetDataValues($data);$p->SetXDataLabelPos('none');$p->SetPlotType('points');$p->DrawGraph();
Another possible way to do this is to overlay multiple plots in one image, but
some weird things can happen there and I haven't gotten around to documenting
how to safely do this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have to confess I think it's a bit of kludge but it works! Writing my array
from my data base data was a bit involved but some of that was my problem. I
have to determine how many series (lines) I'll have at runtime, for example.
Different PlotTypes works fine too. Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh, I completely agree it is a kludge. What your are trying to do just doesn't
fit that well into the PHPlot data type model, which is one independent
variable value with one or more dependent variable values corresponding to it.
And I can't see a way to improve that model to fit this type of situation.
I did think of a 3rd solution that might work better for you. (Might be too
late, sorry, but I thought of this after replying and have not tried it yet.)
Using the data array in your original message, the label field identifies what
series a point belongs to, right? And all you want to do is make the point
color correspond to the series? You could use a custom data color
callback to set the point color based on the label value. If you are
interested, I'll make up a short example.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I like the fact that I can use the different PlotTypes to get connecting lines
or histogramic squared lines. Would your alternative solutions still do that?
Series of (x.y) data pairs occur a lot in engineering and science and
visualizing the raw data before developing a math model is very common. This
might be a productive direction to go for future product development. Later
this might lead to statistical analysis areas and curve fitting (regression
analysis). For now, since what I have works I'm happy. Thank you spending time
on my application.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No, you are right, using a single Y column and data color callback does not
get the results you want with other plot types - only 'points'. I also found
out that with 'points' plots, I can control the color but not the point shape
(marker). All series get the same point shape, because to PHPlot they are the
same data set.
Series of (x,y) data pairs - something for me to think about. Maybe a new data
type for a 3 dimensional data array indexed by series, row, column.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So far I've created multi-line x-y plots but can't see how to make multi-line
scatter plots, ie without same x values. Am I missing something or is this a
feature on its way? So instead of ('', x, y1,y2,y3,...) data I want to plot
( ('seriesA', x1, y1), ('seriesA',x2,y2), ('seriesA',x3,y3)...),
('seriesB',x1,y1), ('seriesB,x2,y2)...)
where all seriesA points form one line of one color and SeriesB another and
all the x,y pairs are independent. Thanks. R
Multi-line scatter ('points') plots are basically the same as multi-line line
plots. But if you want to have independent X values for each Y and keep each
series separate (if I understand what you are trying to do), you have to play
around a little with the data array. If you have 2 series, then for seriesA,
your rows will be: array('', x1, y1, '') and for seriesB your rows will be
array('', x1, '', y1). All these rows are combined into 1 data array. Remember
that the column for Y determines its color. Here is an example with 3 series:
Another possible way to do this is to overlay multiple plots in one image, but
some weird things can happen there and I haven't gotten around to documenting
how to safely do this.
I have to confess I think it's a bit of kludge but it works! Writing my array
from my data base data was a bit involved but some of that was my problem. I
have to determine how many series (lines) I'll have at runtime, for example.
Different PlotTypes works fine too. Thanks.
Oh, I completely agree it is a kludge. What your are trying to do just doesn't
fit that well into the PHPlot data type model, which is one independent
variable value with one or more dependent variable values corresponding to it.
And I can't see a way to improve that model to fit this type of situation.
I did think of a 3rd solution that might work better for you. (Might be too
late, sorry, but I thought of this after replying and have not tried it yet.)
Using the data array in your original message, the label field identifies what
series a point belongs to, right? And all you want to do is make the point
color correspond to the series? You could use a custom data color
callback to set the point color based on the label value. If you are
interested, I'll make up a short example.
I like the fact that I can use the different PlotTypes to get connecting lines
or histogramic squared lines. Would your alternative solutions still do that?
Series of (x.y) data pairs occur a lot in engineering and science and
visualizing the raw data before developing a math model is very common. This
might be a productive direction to go for future product development. Later
this might lead to statistical analysis areas and curve fitting (regression
analysis). For now, since what I have works I'm happy. Thank you spending time
on my application.
No, you are right, using a single Y column and data color callback does not
get the results you want with other plot types - only 'points'. I also found
out that with 'points' plots, I can control the color but not the point shape
(marker). All series get the same point shape, because to PHPlot they are the
same data set.
Series of (x,y) data pairs - something for me to think about. Maybe a new data
type for a 3 dimensional data array indexed by series, row, column.
While you are thinking about it - there's also higher dimensions - like
contour plots based on x,y.z triplets. Multiple series of these might get
difficult to visualize. On the subject of visualization did you see
http://www.visualcomplexity.com/vc/ and
http://insideria.com/2009/12/28-rich-data-visualization-
too.html
Thanks.