MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Joining points of ListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117289] Re: Joining points of ListPlot
  • From: Antonio Mezzacapo <ant.mezzacapo at gmail.com>
  • Date: Mon, 14 Mar 2011 05:58:53 -0500 (EST)

Ok now you've got the point, Michael.
Yeah I was wondering if there was a smart way to achieve the result without
writing an explicit algorithm to separates the curve, also because I have
many of these arrays and I don't want my separating procedure to be very
specific case-dependant.

I guess I should not use Joined this time, it looks too complicated, and it
doesn't worth the effort.

Thank you anyway
Antonio

2011/3/13 Michael Stern <nycstern at gmail.com>

> Antonio,
>
> If I understand the data and what you want to achieve, you have data from
> four separate functions that have been mixed together and you want to
> separate the data and graph it, with each function colored differently. This
> seems to be complicated by the facts that (1) it looks as though you may
> have your data arranged in {dependent variable, independent variable} pairs,
> the opposite of what would usually be the case, (2) some of the independent
> variables are complex numbers, and (3) you have a nonsense number in the
> list ( {}[400]).
>
> I'd remove the nonsense number by hand, then use the Select[] command to
> separate the data for the four curves, using Selection criteria that you are
> going to have to determine by plotting equations against the same axes as
> your data. Once you have them separated you can graph them in any colors you
> want.
>
> Sorry I can't do this four you, but it's going to take a bit of time.
>
> Send any follow-up to me directly.
>
> Thanks,
>
> Michael
>
>
>
> On Mar 13, 2011, at 12:40 PM, Antonio Mezzacapo wrote:
>
> Here's an example of my data. See that from one array one gets different
> functions that i want to join separately. Try to join all the points and it
> will do weird things.
>
> Antonio
>
> 2011/3/13 Michael Stern <nycstern at gmail.com>
>
>> The functional form was in the third example only to generate sample data.
>> The plotting function worked perfectly for that sample data, and should work
>> for your data as well. If you will share some of your data, I can be more
>> explicit. What does your array look like? For example, is it {{function 1
>> point 1, function 2 point 1},{function 2, point 2, function 2 point 2} . . .
>> } or is it {{function 1 point 1, function 1 point 2 . . . }, {function 2
>> point 1, function 2 point 2 . . . }}. Either one is easily handled, but you
>> can't expect us to be psychic.
>>
>> Michael
>>
>>
>>
>>
>> On Mar 13, 2011, at 11:17 AM, Antonio Mezzacapo wrote:
>>
>> Tha problem is that all points are on the same array, and I don't know the
>> functional form they have, so i can't separate the two arrays like you did
>> in your third example.
>> It's like having Sin and Cos points on the same array, but they are not
>> Sin and Cos, and I don't know their analytic form!
>>
>> AM
>>
>> 2011/3/13 Michael Stern <nycstern at gmail.com>
>>
>>> Can you provide an example of your data? Sorting by the independent
>>> variable should give you the results you want, as in my third example.
>>>
>>> MS
>>>
>>> Sent from a mobile device.
>>>
>>> On Mar 13, 2011, at 8:24 AM, Antonio Mezzacapo <ant.mezzacapo at gmail.com>
>>> wrote:
>>>
>>> Thank you for answering.
>>>
>>> I don't have any functional form of this points. I have only this array
>>> of points. Points on this array should be distributed *like* two
>>> crossing functions as Sin[x] and Cos[x], but I don't know the functional
>>> form of these functions.
>>>
>>> All that I have is an array of points!
>>> Because of the fact that these points distribute on the x-y cartesian
>>> plane like two crossing functions, I cannot use "joined->true" because it
>>> gives me strange results.
>>>
>>> Thank you
>>> Antonio
>>>
>>> 2011/3/13 Michael Stern < <nycstern at gmail.com>nycstern at gmail.com>
>>>
>>>> Antonio,
>>>>
>>>> Some points of your question are unclear, but perhaps this will cover
>>>> all relevant cases.
>>>>
>>>> 1. If you have functions, the simplest way is:
>>>>
>>>> Plot[{Sin[x], Cos[x]}, {x, 0, 2*Pi}]
>>>>
>>>> 2. You refer to "joined points," however, which suggests that you may be
>>>> dealing with lists of points rather than functions. If so, you can do the
>>>> same thing as follows:
>>>>
>>>> (* creating the two lists *)
>>>> s1 = Table[Sin[x], {x, 0, 2*Pi, .1}];
>>>> c1 = Table[Cos[x], {x, 0, 2*Pi, .1}];
>>>>
>>>> (* plot *)
>>>> ListPlot[{s1, c1}, Joined -> True]
>>>>
>>>>
>>>> 3. You refer to the points not being ordered, from which I take that one
>>>> or both of the lists of plots has cartesian coordinates, not ordered by the
>>>> independent variable. In this case, you can use Sort or SortBy to put them
>>>> in order.
>>>>
>>>> (* creating two cartesian lists, neither of which is 'ordered' by the
>>>> definition above *)
>>>> s2 = RotateLeft[Table[{x, Sin[x]}, {x, 0, 2*Pi, .1}]];
>>>> c2 = RotateRight[Table[{x, Cos[x]}, {x, 0, 2*Pi, .1}]];
>>>>
>>>> (* plot by sorted versions of these unordered lists *)
>>>> ListPlot[{SortBy[s2, First], SortBy[c2, First]}, Joined -> True]
>>>>
>>>>
>>>> Does that help?
>>>>
>>>> Michael
>>>>
>>>>
>>>> On Mar 13, 2011, at 6:25 AM, Antonio Mezzacapo wrote:
>>>>
>>>> > Hi,
>>>> > here's my problem:
>>>> >
>>>> > I have an array of data depicting two crossing functions (let's say
>>>> like
>>>> > Sin[x] and Cos[x]). How can I arrange them and make a joined points
>>>> plot,
>>>> > that joins only points belonging to the same function?
>>>> > I remember you that the points of the two crossing functions are on
>>>> the same
>>>> > array and they are non-ordered.
>>>> >
>>>> > Thank you
>>>> >
>>>> > Antonio Mezzacapo
>>>> >
>>>>
>>>>
>>>
>>
>>
> <AntonioListPlot.txt>
>
>


  • Prev by Date: Re: Vectorized molecular dynamics with Mathematica?
  • Next by Date: Re: Joining points of ListPlot
  • Previous by thread: Re: Joining points of ListPlot
  • Next by thread: Re: Joining points of ListPlot