-2
$\begingroup$

Is it possible to fill, color, under the points in ListPlot where the points define the area and the boundary? Assuming that the number of points are large enough to be able to define an area by them. I am looking for something similar to the Filling option which is based on the points distribution, rather than the area between curves or axes. Please note that there is no curve in this case, only point, therefore this is not a duplicate question.

Edit: To those who said this is duplicate: Can you read the question properly before jumping to your illogical conclusion? Do you see any similarities between my question and this link as duplicate? ListPlot and filling between curves Please refer to more accurate duplicate otherwise remove the duplicate from this question soon.

Edit: something like this picture (roughly) from this link: https://en.wikipedia.org/wiki/Phase_diagram enter image description here

Edit2: some data points:

{{1.52788, 0.00119755}, {1.70822, 0.00119755}, {1.87126, 0.00119755}, {2.02119, 0.00119755}, {2.16075, 0.00119755}, {2.29182, 0.00119755}, {1.52788, 0.00479019}, {1.70822, 0.00479019}, {1.87126, 0.00479019}, {2.02119, 0.00479019}, {1.52788, 0.00718529}, {1.70822, 0.00718529}, {1.87126, 0.00718529}, {1.52788, 0.00958039}, {1.70822, 0.00958039}, {1.52788, 0.0119755}, {1.70822, 0.0119755}, {1.52788, 0.0179632}, {1.70822, 0.0179632}, {1.52788, 0.0215559}, {1.70822, 0.0215559}, {1.52788, 0.023951}, {1.70822, 0.023951}, {1.52788, 0.0299387}, {1.70822, 0.0299387}, {1.52788, 0.0359265}, {1.70822, 0.0359265}, {1.52788, 0.0419142}, {1.70822, 0.0419142}, {1.52788, 0.0479019}, {1.70822, 0.0479019}, {1.52788, 0.0598774}, {1.70822, 0.0598774}, {1.52788, 0.0718529}, {1.70822, 0.0718529}, {1.52788, 0.0838284}, {1.70822, 0.0838284}, {1.52788, 0.107779}, {1.70822, 0.107779}, {1.87126, 0.107779}, {1.52788, 0.163525}, {1.70822, 0.163525}, {1.87126, 0.163525}, {1.52788, 0.204406}, {1.70822, 0.204406}, {1.87126, 0.204406}, {1.52788, 0.245288}, {1.70822, 0.245288}, {1.87126, 0.245288}, {2.02119, 0.245288}}

$\endgroup$
  • $\begingroup$ can you show a small sample data? $\endgroup$ – Sumit Jun 23 '16 at 9:33
  • $\begingroup$ @Sumit, I have included an image, thanks. $\endgroup$ – O_o Jun 23 '16 at 9:47
  • $\begingroup$ Do you have data for each phase line or only the crossing points? $\endgroup$ – Sumit Jun 23 '16 at 9:52
  • 1
    $\begingroup$ I don't think you can make a phase diagram with this data. Either you need set of points on each boundary, or a third column specifying the phase. Otherwise you can't sort out different regions. $\endgroup$ – Sumit Jun 23 '16 at 10:20
  • 3
    $\begingroup$ Whether this is a duplicate or not, your comment to closers is impolite. Rather than ordering people around, you will get much better feedback if you reply to comments - which people took time to write to e.g. clarify your question. $\endgroup$ – Yves Klett Jun 24 '16 at 15:20
5
$\begingroup$

Okay, so you have a set of Regions that you want to fill, but you can only define those regions by a set of points distributed within them. Let's make some data that reproduces this. Here are three non-overlapping regions that fill up a square:

region1 = Disk[{0, 0}, 1, {0, π/2}];
region2 = RegionDifference[Rectangle[], region1];
region3 = Disk[{0, 0}, 1, {0, π/6}];
region1 = RegionDifference[region1, region3];
RegionPlot[{region1, region2, region3}]

Mathematica graphics

That's what we want to get in the end. Now let's get a 1000 random points in each region,

{points1, points2, points3} = 
  RandomPoint[#, 1000] & /@ {region1, region2, region3};
ListPlot[{points1, points2, points3}]

Mathematica graphics

Okay, so now you might think that you can just make a convex hull for each set of points to define the regions,

RegionPlot[Evaluate[
  ConvexHullMesh /@ {points1, points2, points3}]]

Mathematica graphics

but clearly you'd be wrong. What you need is a concave hull in this case, otherwise known as an alpha shape. I took the code from this post and put it on gist to make it easy to import,

<<"https://gist.github.com/jasondbiggs/39fac60c578e57959b979cfd8e43f7d6/raw/7c012d631b58ad77815999a31b8cce8761e4dcfe/alphashapes_2D.m"
RegionPlot[Evaluate[
  alphaShapes2DC[#, 0.1] & /@ {points1, points2, points3}]]

Mathematica graphics

A decent approximation, but not a perfect representation of the regions. OP did say

Assuming that the number of points are large enough to be able to define an area

So if I increase the number of points to 10,000 for each region than this is what results

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thank you so much, a combination of your method and other's suggestion (Sumit and E.Doroskevic) to have a third column solved the problem! $\endgroup$ – O_o Jun 23 '16 at 13:22
0
$\begingroup$

Example

Code

ListPlot[Range @ 100, Filling -> Bottom]
ListLinePlot[Range @ 100, Filling -> Bottom]

Output

example 1 example 2

Reference

Filling
ListPlot
ListLinePlot

$\endgroup$
  • $\begingroup$ Thank you, but I am looking for something different. Suppose that we have distribution of points in X-Y plane with higher densities in some regions and I would like to use fill and color based on the distribution of the points. $\endgroup$ – O_o Jun 23 '16 at 9:40
  • $\begingroup$ Would you have some data we would be able to use? $\endgroup$ – e.doroskevic Jun 23 '16 at 9:48
  • $\begingroup$ Added some data points. $\endgroup$ – O_o Jun 23 '16 at 9:57
  • $\begingroup$ @O_o ListLinePlot[data, Filling -> Bottom, ColorFunction -> "TemperatureMap"] wheredata is your list of points? $\endgroup$ – e.doroskevic Jun 23 '16 at 10:07
  • 1
    $\begingroup$ @O_o I agree with @Sumit, you need to have three data sets indicating curves associated with ea. phase you want to visualize in a Plot. Given this information is available, you will be able to use ListLinePlot with Filling->Bottom to get desired output $\endgroup$ – e.doroskevic Jun 23 '16 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.