0

I'm using android plot library to plot data from an array I have. The problem is when there are duplicate data in the array , some number labels of the y axis are also being duplicated. for example if I have an array

{46.66,46.50,46.61,46.61,46.55,46.55,46.60,46.50,46.50,46.50,46.61,46.41,46.54,46.44,46.46,46.55,46.59,46.61,46.64,46.60,46.65,46.74,46.74,46.99,46.95,46.94,46.80,46.98,46.90,46.94,47.00,46.94,47.11 }

I get 46.6 and 47 duplicated on the y-axis.

Sorry I couldn't post an image because of my low reputation.

Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
user2469133
  • 1,940
  • 3
  • 21
  • 33
  • Do you need to get the array sorted and duplicate values removed or only duplicate values removed ? – Niko Jan 11 '14 at 06:32

1 Answers1

0

You could consider using a Set for unique values allowing no duplicates:

A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.

If you decide to stick with ArrayList there are many posts about removing duplicates or making extended class to disallow same values added:

How to remove Duplicate value from arraylist in Android

Community
  • 1
  • 1
Niko
  • 8,093
  • 5
  • 49
  • 85
  • i thought of this, but wouldn't that decrease the size of the arraylist and remove values i want to plot, so for example if i have 20 values and 5 duplicates, then i would have 15 values instead of 20 and this is not right for my graph. – user2469133 Jan 11 '14 at 12:22
  • The image of your graph now and image of graph wanted would help a lot in this, can you post images somewhere else and provide links? – Niko Jan 11 '14 at 12:24
  • Okay I see, why the graph is not correct if you remove duplicate values? – Niko Jan 11 '14 at 12:53
  • because it represents real data, removing a duplicate is like removing a record that should be included even if it was repeated – user2469133 Jan 11 '14 at 14:03
  • i think it's a bug in this library – user2469133 Jan 11 '14 at 14:03
  • Ah I understand, can't help any further unless you have the library source code and you can modify that to fix the issue. – Niko Jan 11 '14 at 14:08