Message Boards Message Boards

0
|
5628 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do I plot text instead of points?

Posted 9 years ago

I've got some data, a subset of which looks like this:

fqData = {
   <| "Application" -> "Chess", "x" -> 9.0, "y" -> 2.5|>,
   <| "Application" -> "Drive", "x" -> 7.0, "y" -> 8.5|>

   };

I've mapped the x and y coordinates to a list, and used ListPlot to plot those points. But instead of seeing standard markers at each point, I would prefer to plot the actual label values, like "Chess" and "Drive", so something like the following, only with the correct labels in each place.

enter image description here

I thought PlotMarkers would do the trick for me (its how I got the above), but if you want to vary the plot markers, it only seems to apply to whole lists, so only useful in a situation where you are plotting a list of lists, where x axis values are assumed, and each point from a given sub-list is the same.

Any suggestions?

Thanks

Brad

POSTED BY: Brad Varey
3 Replies

Not sure, but I think this is like what you want:

fqData = {<|"Application" -> "Chess", "x" -> 9.0, "y" -> 2.5|>,
   <|"Application" -> "Drive", "x" -> 7.0, "y" -> 8.5|>,
   <|"Application" -> "Chess", "x" -> 2.0, "y" -> 5.5|>}

datasets = GatherBy[fqData, #["Application"] &];

ListPlot[{#["x"], #["y"]} & /@ # & /@ datasets,
 PlotMarkers -> (First[#]["Application"] & /@ datasets),
 PlotRangePadding -> {Scaled[.06], Automatic}]

The plot range needed a little extension to include the names, which are considerably wider than points.

POSTED BY: Michael Rogers
Posted 9 years ago

Thanks.

I had considered Graphics[], but was hoping to leverage ListPlot[], because it gives me access to some options Graphics[] does not on its own (if I understand correctly), like PlotTheme.

And the workbook I am writing contains plenty of other charts where ListPlot[] would be ideal. Sticking to one base plotting function would be best for me.

POSTED BY: Brad Varey
Graphics[
 {Text["Chess", {9, 2.5}],
  Text["Drive", {7, 8.5}]},
 PlotRange -> {{0, 10}, {0, 10}},
 Frame -> True,
 BaseStyle -> {FontSize -> 12}]
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