2
$\begingroup$

i have some c++ output (just two coordinates of one point on each line in a a .csv file) that i want to evaluate using Mathematica.

those points correspond to matrix elements. so i want my ListPlot to start in the left top corner with coordinates (0,0) but i found no nice way to flip the orientation of the Y-axis.

my workaround so far is to change every y coordinate of all points to -y so it counts down. but thats very unclean.

ListPlot[{dataq0, dataq1}, PlotStyle -> PointSize[0.02], Frame -> True, 
 FrameLabel -> {None, None}, AxesOrigin -> Automatic]

this is how it looks now with y=-y

the second thing, but that is not that important would be to have the X-axis on top of the plot.

if one of you knows how to do such - help would be much appreciated.

$\endgroup$
4
  • $\begingroup$ Perhaps you might be interested in ArrayPlot or MatrixPlot: from the docs "ArrayPlot[array] by default arranges successive rows of array down the page and successive columns across, just as a table or grid would normally be formatted". $\endgroup$
    – MarcoB
    Oct 22, 2015 at 15:19
  • $\begingroup$ Are you sure you want ListPlot and not ArrayPlot or MatrixPlot? They have the ordering in the way you want. To get the Ticks only to the correct edges look up FrameTicks option, which allows you to specify different settings for different sides. $\endgroup$
    – Johu
    Oct 22, 2015 at 15:20
  • $\begingroup$ i was thinking about Array/Matrix Plot but the structure of my import has the form: i.imgur.com/3wNttA0.png so its {{x1,x2}, ... ,{xn,yn}} - and it would need some sophisticated way to convert it into a matrix-form where every entry corresponds to how often said point was found in the dataset. $\endgroup$
    – tristan
    Oct 22, 2015 at 15:34
  • $\begingroup$ This question has been answered before flipping y axis $\endgroup$ Oct 23, 2015 at 23:17

1 Answer 1

5
$\begingroup$

The documentation for ScalingFunctions doesn't reveal it, but it can also be used for ListPlot. There is only one difference compared to the examples in the documentation, it has to be used as an option to the Method option of ListPlot.
One can use the option FrameTicks -> {Automatic, {None, All}} to get "the X-axis on top of the plot".

dataq0 = RandomInteger[{0, 16}, {250, 2}];
dataq1 = RandomInteger[{0, 15}, {250, 2}];

ListPlot[{dataq0, dataq1}, PlotStyle -> PointSize[0.02], 
 Frame -> True, Method -> ScalingFunctions -> {Identity, "Reverse"}, 
 FrameTicks -> {Automatic, {None, All}}]

Plot

$\endgroup$
1
  • $\begingroup$ AMAZING Method -> ScalingFunctions -> {Identity, "Reverse"} did exactly what i was looking for. thanks alot! cheers $\endgroup$
    – tristan
    Oct 22, 2015 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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