私は(x、y)に3列、x、y、値のデータセットを持っています。私はマップを下図のようにプロットしたいと思います。どのようにjfreechartやこの種のプロットに利用できるライブラリでこのタイプの図をプロットするのですか?Javaでカラーマップをプロットする方法は?
答えて
あなたは3列のデータセットを説明するためにBubbleChartを使用することができます。
かなりよく見えるいくつかのチャートを含むいくつかのアンドロイドのライブラリがあります。 Android用
HelloCharts:https://github.com/lecho/hellocharts-android
MPAndroidChart:これはあなたの問題を解決https://github.com/PhilJay/MPAndroidChart
希望。
XYBlockRenderer
はよく似ています。 Color.getHSBColor()
は、hereと表示されているように、PaintScale
にすることができます。
はい。これを試みましたが、出力イメージが滑らかではありません。レンダリングの幅と高さを変えてみました。 – Ranjeet
どのような解像度を使いましたか?例は100 x 100ブロック、 –
このexampleで開始し、このideaを使用して、以下のように、あなたは色のパレットを取得するためにSpectrumPaintScale
を使用することができます。
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Paint;
import javax.swing.JFrame;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.PaintScale;
import org.jfree.chart.renderer.xy.XYBlockRenderer;
import org.jfree.chart.title.PaintScaleLegend;
import org.jfree.data.xy.DefaultXYZDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYZDataset;
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RectangleInsets;
/** @see https://stackoverflow.com/a/37235165/230513 */
public class XYZChartDemo {
private static final int N = 1000;
public XYZChartDemo(String title) {
JFrame f = new JFrame(title);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ChartPanel chartPanel = new ChartPanel(createChart(createDataset())) {
@Override
public Dimension getPreferredSize() {
return new Dimension(640, 480);
}
};
chartPanel.setMouseZoomable(true, false);
f.add(chartPanel);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
private static JFreeChart createChart(XYDataset dataset) {
NumberAxis xAxis = new NumberAxis("x Axis");
NumberAxis yAxis = new NumberAxis("y Axis");
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
XYBlockRenderer r = new XYBlockRenderer();
SpectrumPaintScale ps = new SpectrumPaintScale(0, N * N);
r.setPaintScale(ps);
r.setBlockHeight(10.0f);
r.setBlockWidth(10.0f);
plot.setRenderer(r);
JFreeChart chart = new JFreeChart("Title",
JFreeChart.DEFAULT_TITLE_FONT, plot, false);
NumberAxis scaleAxis = new NumberAxis("Scale");
scaleAxis.setAxisLinePaint(Color.white);
scaleAxis.setTickMarkPaint(Color.white);
PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis);
legend.setSubdivisionCount(128);
legend.setAxisLocation(AxisLocation.TOP_OR_RIGHT);
legend.setPadding(new RectangleInsets(10, 10, 10, 10));
legend.setStripWidth(20);
legend.setPosition(RectangleEdge.RIGHT);
legend.setBackgroundPaint(Color.WHITE);
chart.addSubtitle(legend);
chart.setBackgroundPaint(Color.white);
return chart;
}
private static XYZDataset createDataset() {
DefaultXYZDataset dataset = new DefaultXYZDataset();
for (int i = 0; i < N; i = i + 10) {
double[][] data = new double[3][N];
for (int j = 0; j < N; j = j + 10) {
data[0][j] = i;
data[1][j] = j;
data[2][j] = i * j;
}
dataset.addSeries("Series" + i, data);
}
return dataset;
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new XYZChartDemo("XYZ Demo");
}
});
}
private static class SpectrumPaintScale implements PaintScale {
private static final float H1 = 0f;
private static final float H2 = 1f;
private final double lowerBound;
private final double upperBound;
public SpectrumPaintScale(double lowerBound, double upperBound) {
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}
@Override
public double getLowerBound() {
return lowerBound;
}
@Override
public double getUpperBound() {
return upperBound;
}
@Override
public Paint getPaint(double value) {
float scaledValue = (float) (value/(getUpperBound() - getLowerBound()));
float scaledH = H1 + scaledValue * (H2 - H1);
return Color.getHSBColor(scaledH, 1f, 1f);
}
}
}
- 1. カラーマップのスケールを一定に保ち、カラーバーをプロットする方法
- 2. 3Dプロットでのカラーマップの使用方法は?
- 3. matplotlib画像プロットのフィジー「HiLo」カラーマップを達成する方法
- 4. bar3dプロットのカラーマップ/カラー問題
- 5. matplotlibプロットの横にカラーマップを作成して、データをプロットすることなくカラーマップを作成する
- 6. Pythonでxy座標を使用してカラーマップをプロットする
- 7. python matplotlibカラーマップは後続のプロットでも継承されます
- 8. Pythonでカラーマップをプロットしようとしています
- 9. VisPyサーフェスプロットでのカラーマップの使用方法
- 10. 値に基づいてカラーマップを作成する方法は?
- 11. グレー画像のカラーマップを表示する方法は?
- 12. renjinを使用してJavaでプロットする方法
- 13. Androidでグラフをプロットする方法は?
- 14. Pythonでバイナリカラーヒストグラムをプロットする方法は?
- 15. matplotlibでヒートマップをプロットする方法は?
- 16. Matplotlibでデフォルトのカラーマップを設定する方法
- 17. Sassのカラーマップで線形勾配を設定する方法
- 18. Pythonのインタラクティブプロットアニメーションでカラーマップを設定する方法
- 19. matplotlibで2Dカラーマップをスムーズにする方法
- 20. オフラインでプロットして縦線をプロットする方法は?
- 21. semilogxプロットでx = 0をプロットする方法は?
- 22. Javaでメッシュグリッドサーフェスをプロットする
- 23. カラーマップが動作する軸を変更する方法
- 24. カスタムレベルのmatplotlib contourfプロットのカラーマップが無視されています
- 25. HyperTrackでカラーマップを取得するには?
- 26. ggplot2を使ってfilled.contourプロットをプロットする方法は?
- 27. :depth_first_visitを使用する方法、問題カラーマップ
- 28. OpenCVの異なるカラーマップ間の変換方法は?
- 29. はScilabで複数のプロットをプロットする速い方法です
- 30. ラズベリー+センサーをプロットする方法は? Python
詳細な議論[ここ](http://www.jfree.org/forum/viewtopic.php?f=3&t=29588)。 – trashgod