Message Boards Message Boards

0
|
1732 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How can you flip the axis values in ListLinePlot?

Posted 1 year ago

John Baez has requested a labeled plot of the first fifty primes on his Mathodon blog.
The code:

ListLinePlot[Labeled[#, #] & /@ Table[Prime[n], {n, 46}], 
PlotStyle -> PointSize[Medium]]

is close to what is desired with two exceptions:
- The values displayed on the x and y axis should be switched. The x-axis should run from 1 to 200 and the y-axis from 1 to 50.
- Each point should be labeled.

Baez plot of the primes to be replicated with the points labeled.

Baez plot of the primes to be replicated with the points labeled.

POSTED BY: Daniel Geisler
2 Replies

Daniel,

just a remark - you can achieve the same by simply plotting the PrimePi-function:

Plot[PrimePi[x], {x, 0, 200}]

If you do it your way you probably might consider the option InterpolationOrder:

ListLinePlot[Table[{Prime[n], n}, {n, 46}], 
 PlotStyle -> PointSize[Medium], InterpolationOrder -> 0]
POSTED BY: Henrik Schachner

I noticed I had the entire graph inverted, so the answer was just to use

ListLinePlot[Table[{Prime[n], n}, {n, 46}], 
 PlotStyle -> PointSize[Medium]]
POSTED BY: Daniel Geisler
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract