JFreechart - XY步骤图范围和精度问题(JFreechart - XY Step Chart range and precision issues)
我正在尝试分别使用下面的X和Y值创建一个XY步骤图。 但是,我几乎没有问题
- X轴和Y轴的范围太粗糙 ,因此未显示图表上的所有数据点。 如何自己设定范围和精度?
- 我很困惑为什么X轴范围显示为19:00:00:025 。 这与我添加的数据项不匹配。
码
final XYSeries series = new XYSeries("Random Data"); for (Coordinate c : coordinates) { series.add(c.x, c.y); } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYStepChart("XY Series Demo", "Latitude.before " + builder.getBeforeSimplifySize(), "Longitude.after " + builder.getAfterSimplifySize(), data, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYSplineRenderer renderer = new XYSplineRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); plot.setRenderer(renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(1000, 1000)); setContentPane(chartPanel);
图表图像
数据(X,Y)
22.11845833328035, 21.7640694448683 22.118927777873147, 21.767827777730094 22.119402777883742, 21.771577777862547 22.11986111111111, 21.775330555703903 22.120297222137452, 21.779052777820162 22.1207694445716, 21.782777777777778 22.12122777779897, 21.786499999894037 22.121691666709054, 21.790222222010296 22.12238333331214, 21.793791667090524 22.124313889079623, 21.794461111492584 22.125488888952468, 21.792299999660916 22.126555555131702, 21.789572221967912 22.127716666327583, 21.786597222222223 22.128902777565852, 21.78352499999934 22.12928055551317, 21.780111111534964 22.12799444410536, 21.777344444062972 22.126263888676963, 21.77588611072964 22.1247833331426, 21.774636111259458 22.12351944446564, 21.77356666670905 22.12268888897366, 21.77209999985165 22.12205555544959, 21.770461111068723 22.12130833307902, 21.76895277765062 22.120730555587347, 21.76736111111111 22.12099722226461, 21.76573333316379 22.121925000084772, 21.765163888931273 22.122738889058432, 21.765847222010294 22.12294444455041, 21.767177777787047 22.12261111100515, 21.76862500005298 22.12194166660309, 21.76981666670905 22.120891666677263, 21.769922222296398 22.1201444445716, 21.76878055559264 22.119852777851953, 21.767180555562177 22.11962222231759, 21.76557499991523 22.11872777779897, 21.7645194445716 22.11762222223812, 21.76518888897366 22.117516666650772, 21.767211111121707 22.118702777756585, 21.7682361111376 22.120177777873145, 21.76688611111707 22.11994166665607, 21.764588889016046 22.118886111047534, 21.76399722205268 22.117880555523765, 21.763383333418105 22.11763333333863, 21.762047221925524 22.1186000000106, 21.760833333333334 22.1199277777142, 21.760519444147747 22.12074999994702, 21.75909999953376 22.120244444476235, 21.757891666624282 22.119372222158646, 21.757316666709052 22.118452777730095, 21.756691666709052 22.118022222254012, 21.75526111125946 22.11852222217454, 21.75406388892068 22.119263888994855, 21.75299444437027 22.119561111132306, 21.751650000015896 22.118716666698457, 21.75051666667064 22.117644444439147, 21.75164722217454 22.118058333396913, 21.7530166665713 22.118777777751287, 21.7538583334287 22.119766666624283, 21.754372222158644 22.12112777762943, 21.75402777777778 22.122155555619134, 21.75211111108462 22.121849999957615, 21.749758333630034 22.12074166668786, 21.748875000211928 22.119677777820165, 21.748883333206177 22.118625000052983, 21.748944444656374 22.11725277774864, 21.74952222188314 22.116283333036638, 21.751622222264608 22.116841666665344, 21.75414166662428 22.11861111111111, 21.75535000006358 22.12064722220103, 21.756391666730245 22.122597222328185, 21.757097222010295 22.124005555576748, 21.756288888719347 24.125258333418106, 23.755583333439297 26.12644444465637, 25.754974999957614 28.127694444656374, 27.754299999872842 29.129219444062976, 28.75346111112171 30.130997222264607, 29.752511111100514 31.13303055551317, 30.75141111108992 35.13517777774069, 34.75021666665872 36.13741666661368, 35.74901111072964 39.13970833354526, 38.747786110772026 40.14173888895247, 39.74669444402059
I am trying to create a XY step chart with the below X and Y values respectively. However, I've few issues
- the ranges for X and Y axis are too coarse grained and hence not showing all the data points on the graph. How can I set the range and precision myself?
- I am confused on why the X axis ranges are displayed like 19:00:00:025. This is not matching the data items i am adding.
Code
final XYSeries series = new XYSeries("Random Data"); for (Coordinate c : coordinates) { series.add(c.x, c.y); } final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYStepChart("XY Series Demo", "Latitude.before " + builder.getBeforeSimplifySize(), "Longitude.after " + builder.getAfterSimplifySize(), data, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYSplineRenderer renderer = new XYSplineRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); plot.setRenderer(renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(1000, 1000)); setContentPane(chartPanel);
Chart Image
Data (X, Y)
22.11845833328035, 21.7640694448683 22.118927777873147, 21.767827777730094 22.119402777883742, 21.771577777862547 22.11986111111111, 21.775330555703903 22.120297222137452, 21.779052777820162 22.1207694445716, 21.782777777777778 22.12122777779897, 21.786499999894037 22.121691666709054, 21.790222222010296 22.12238333331214, 21.793791667090524 22.124313889079623, 21.794461111492584 22.125488888952468, 21.792299999660916 22.126555555131702, 21.789572221967912 22.127716666327583, 21.786597222222223 22.128902777565852, 21.78352499999934 22.12928055551317, 21.780111111534964 22.12799444410536, 21.777344444062972 22.126263888676963, 21.77588611072964 22.1247833331426, 21.774636111259458 22.12351944446564, 21.77356666670905 22.12268888897366, 21.77209999985165 22.12205555544959, 21.770461111068723 22.12130833307902, 21.76895277765062 22.120730555587347, 21.76736111111111 22.12099722226461, 21.76573333316379 22.121925000084772, 21.765163888931273 22.122738889058432, 21.765847222010294 22.12294444455041, 21.767177777787047 22.12261111100515, 21.76862500005298 22.12194166660309, 21.76981666670905 22.120891666677263, 21.769922222296398 22.1201444445716, 21.76878055559264 22.119852777851953, 21.767180555562177 22.11962222231759, 21.76557499991523 22.11872777779897, 21.7645194445716 22.11762222223812, 21.76518888897366 22.117516666650772, 21.767211111121707 22.118702777756585, 21.7682361111376 22.120177777873145, 21.76688611111707 22.11994166665607, 21.764588889016046 22.118886111047534, 21.76399722205268 22.117880555523765, 21.763383333418105 22.11763333333863, 21.762047221925524 22.1186000000106, 21.760833333333334 22.1199277777142, 21.760519444147747 22.12074999994702, 21.75909999953376 22.120244444476235, 21.757891666624282 22.119372222158646, 21.757316666709052 22.118452777730095, 21.756691666709052 22.118022222254012, 21.75526111125946 22.11852222217454, 21.75406388892068 22.119263888994855, 21.75299444437027 22.119561111132306, 21.751650000015896 22.118716666698457, 21.75051666667064 22.117644444439147, 21.75164722217454 22.118058333396913, 21.7530166665713 22.118777777751287, 21.7538583334287 22.119766666624283, 21.754372222158644 22.12112777762943, 21.75402777777778 22.122155555619134, 21.75211111108462 22.121849999957615, 21.749758333630034 22.12074166668786, 21.748875000211928 22.119677777820165, 21.748883333206177 22.118625000052983, 21.748944444656374 22.11725277774864, 21.74952222188314 22.116283333036638, 21.751622222264608 22.116841666665344, 21.75414166662428 22.11861111111111, 21.75535000006358 22.12064722220103, 21.756391666730245 22.122597222328185, 21.757097222010295 22.124005555576748, 21.756288888719347 24.125258333418106, 23.755583333439297 26.12644444465637, 25.754974999957614 28.127694444656374, 27.754299999872842 29.129219444062976, 28.75346111112171 30.130997222264607, 29.752511111100514 31.13303055551317, 30.75141111108992 35.13517777774069, 34.75021666665872 36.13741666661368, 35.74901111072964 39.13970833354526, 38.747786110772026 40.14173888895247, 39.74669444402059
原文:https://stackoverflow.com/questions/8264135
最满意答案
有了LIKE你有三种方法。
1)如果它包含相同顺序的所有单词(关键词:一架飞机)
SELECT * FROM descriptions WHERE description LIKE('%One airplane%');
2)如果它包含所有单词但其他顺序无关紧要
SELECT * FROM descriptions WHERE description LIKE('%One%') AND description LIKE('% airplane%');
3)如果它包含一些单词
SELECT * FROM descriptions WHERE description LIKE('%One%') OR description LIKE('% airplane%');
现在,您可以选择对搜索的严格程度。
如果您想使用第二个或第三个实现,您将使用“space”将关键字分割为字符串,并为数组中的每个项添加类似的内容。
With LIKE you have three approaches.
1) If it contains all the words in the same order (Keywords: One airplane)
SELECT * FROM descriptions WHERE description LIKE('%One airplane%');
2) If it contains all the words but ther order doesn't matter
SELECT * FROM descriptions WHERE description LIKE('%One%') AND description LIKE('% airplane%');
3) If it contains some of the words
SELECT * FROM descriptions WHERE description LIKE('%One%') OR description LIKE('% airplane%');
Now you can choose how strict do you want to be with the searches.
If you want to go with the second or third implementation you will be spliting the string with the keywords by "space" and adding a like for each item in the array.
相关问答
更多-
有什么数据库专业书籍介绍?[2022-05-19]
mysql -
正如MySQL手册所说: 包含在双引号(“”“)字符中的短语仅与包含该短语的行相匹配,因为它是键入的。 我们来看一下示例表格: mysql> select * from articles; +----+-----------------------+------------------------------------------+ | id | title | body | +----+------- ...
-
有了LIKE你有三种方法。 1)如果它包含相同顺序的所有单词(关键词:一架飞机) SELECT * FROM descriptions WHERE description LIKE('%One airplane%'); 2)如果它包含所有单词但其他顺序无关紧要 SELECT * FROM descriptions WHERE description LIKE('%One%') AND description LIKE('% airplane%'); 3)如果它包含一些单词 SELECT * FROM d ...
-
关于MySQL的可爱之处,取决于你的观点。 它会将数据视为您认为需要如何处理的数据。 1 + '1' ? 非常清楚你想把字符串视为一个数字,所以它很乐意为你执行添加。 也适用于布尔操作数(只需要观察运算符优先级)。 (a like '%foo%') + (a like '%bar%')识别数字上下文,将布尔结果true视为1 ,将布尔结果false视为0 - 基本上为您计算关键字匹配。 你怎么用? 拿你的where子句,替换所有or用+ ,并确保每个like语句都包含在括号中,然后order by 。 例如 ...
-
你可以运行查询, 循环记录并将描述一起添加到一个大的快乐字符串中。 然后,你可以通过''进入阵列爆炸 使用array_count_values()获取值数组 按降序重新排序arsort() 更新 示例代码: $string = ''; foreach (your_result_set as one_row) { $string .= $one_row['text']; } $data = explode(' ', $string); $data = array_count_values($dat ...
-
我不知道你为什么两次调用mysqli_query ,也许这是你的代码的上下文。 我建议你总是让SQL服务器来完成这些工作。 接口语言(尤其是php)可能不如SQL服务器那么高效。 我的建议是在WHERE子句中使用OR运算符,因此您只发送一个查询。 $selx = "SELECT * FROM sicks WHERE (tags LIKE '%{$_POST['a0']}%' OR tags LIKE '%{$_POST['a1']}%' OR tags LIKE '%{$_POST['a2']}%' O ...
-
在我的例子中,我假设你的模型定义如下: class Item(Base): id = Column(Integer, primary_key=True) title = Column(String) date = Column(Date) 要为关键字构建OR条件,可以使用or_() : >>> keywords = ['word1', 'word2', 'word3'] >>> keywords_condition = or_(*[Item.title.like('%{}%'.fo ...
-
尝试这个: SELECT title FROM mytable WHERE title LIKE '%Ho%windo%' Try this: SELECT title FROM mytable WHERE title LIKE '%Ho%windo%'
-
为什么我的php / mysql搜索字符串只与LAST关键字匹配?(why is my php/mysql search string only matching the LAST keyword?)[2022-06-07]
像这样 $sr=''; foreach(explode(" ",$keywords_search) as $value){ $sr .= " a.name LIKE '%".$value."%' AND"; } $query[] = substr($sr,0,-4); 你忘了放一个. 附加。 make it like this $sr=''; foreach(explode(" ",$keywords_search) as $value){ $sr .= " a.name LIKE ... -
您可以考虑通过REGEXP的正则表达式将单词分隔成一个或一组。 SELECT * FROM tbl WHERE LOWER(`text`) REGEXP '\b(the|quick|fox)\b' 火柴: 快速的棕色狐狸跳过那只懒惰的狗 快点 ,拿到狐狸 ! 我吃了蛋糕 不匹配 布朗狗 在PHP内部,您可以通过将空格上的搜索字符串拆分并将其重新嵌入到|来构造此表达式 逃脱每个组件后。 $str = "the quick brown fox"; $kwds = explode(" ", $str); ...