30363

JFreeChart x axis Format

Question:

How to format x axis labels? I have a chart(look at attach1) <img alt="attache1" class="b-lazy" data-src="https://i.stack.imgur.com/RIY8B.jpg" data-original="https://i.stack.imgur.com/RIY8B.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /> I need to change x axis labels to the labels in the next attach (but with the same chart) <img alt="attach2" class="b-lazy" data-src="https://i.stack.imgur.com/TErMH.jpg" data-original="https://i.stack.imgur.com/TErMH.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer1:

To set the label of the axis (in your example "counts") call

XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLabel("counts");

To change the number format of the axis call

XYPlot plot = (XYPlot) chart.getPlot(); ((NumberAxis)plot.getDomainAxis()).setNumberFormatOverride(new DecimalFormat("0"));

To change the visible range of the plot call

XYPlot plot = (XYPlot) chart.getPlot(); ((NumberAxis)plot.getDomainAxis()).setRange(0,20);

Recommend

  • Display name for nested complex type
  • ggplot2: Plotting regression lines with different intercepts but with same slope
  • How to Wrap words in UILabel
  • Docker volume mount doesn't exist
  • d3.js - Tree Layout - How can I flip it?
  • R - Phylogram labels to vector
  • multiple colors on beanplot in R
  • How to override JAXB @XMLAccessorType(XMLAccessType.FIELD) specified at a Class level with @XMLEleme
  • How to test labels in QTP
  • How to get the probabilities of classes in Spark Naive Bayes classifier?
  • how to set space Between Labels of xAxis
  • Facebook Open Graph Story Custom Actions Keep Getting Rejected - Advice Please?
  • finding symmetric difference/unique elements in multiple arrays in javascript
  • How to mount dynamically single file component in Vue.js
  • Add items to ComboBox at runtime?
  • LatLong falls within a given polygon in D3 + Leaflet
  • Remove every nth element from swift array
  • Trouble Attaching Call Back to Unobtrusive Validation Show Error
  • Keep same scale in different graphs ggplot2
  • JFreechart X and Y axis scaling
  • Neo4j Cypher query performance optimization
  • Neo4j: Legacy Indexes and auto index vs new label bases schema indexes
  • PyQt4 application on Windows is crashing on exit
  • Activation Function choice for Neural network
  • xcode don't localize specific strings
  • Breaking out column by groups in Pandas
  • Swift: Switch statement fallthrough behavior
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • How to model a transition system with SPIN
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • Is it possible to post an object from jquery to bottle.py?
  • reshape alternating columns in less time and using less memory
  • Python/Django TangoWithDjango Models and Databases