R中的螺旋图(Spiral Graph in R)
如何在R中创建螺旋图? 有没有用于这种分析的软件包? 或者有没有其他方式可视化时间导向的数据(关于周期性)?
How to create a spiral graph in R? Is there any package for this kind of analysis? Or is there any other way to visualize time oriented data (regarding periodicity)?
原文:https://stackoverflow.com/questions/6828350
最满意答案
为什么这张地图3的大小?
线条
iss.str(line); iss >> word; word = fn1(word); mp[word] += 1;
只抓住一行的第一个单词并将其添加到地图中。 如果查看文本文件的第一个单词,则只有三个唯一单词。
我以为它会是14,计算文本文件中的每个单词。
尝试这个:
int main () { map<string, long> mp; string line, word; ifstream f_in("text.txt"); while (getline(f_in, line)){ // Construct this object inside the loop. // You don't need it outside this loop. istringstream iss(line); while ( iss >> word ) { word = fn1(word); mp[word] += 1; } } std::cout << mp.size() << std::endl; return 0; }
Why is the size of this map 3?
The lines
iss.str(line); iss >> word; word = fn1(word); mp[word] += 1;
only grab the first word of a line and add it to the map. If you look at the first words of the text file, you only have three unique words.
I thought it would be 14, counting every word in the text file.
Try this:
int main () { map<string, long> mp; string line, word; ifstream f_in("text.txt"); while (getline(f_in, line)){ // Construct this object inside the loop. // You don't need it outside this loop. istringstream iss(line); while ( iss >> word ) { word = fn1(word); mp[word] += 1; } } std::cout << mp.size() << std::endl; return 0; }
相关问答
更多-
初始化STL“地图”大小(initialize an STL `map` size)[2024-01-09]
有几种选择: 您可以尝试使用statefull分配器的映射。 例如来自Boost.Container或C ++ 11。 或者,如果您接受非状态分配器的限制,那么您甚至可以使用C ++ 98/03中的映射。 考虑使用unordered_map(再次来自Boost或C ++ 11) - 它需要将存储区计为构造器参数。 它不同于map,因为它基于散列而不是严格的弱排序。 另一个选项是来自Boost的 flat_map。 它具有保留成员功能。 平面地图/集合的描述 : Boost.Container flat_ [ ... -
不要执行setup_map()函数。 window.onload = function() { //first setup the map, with our default location of London setup_map(51.5073509, -0.12775829999998223); document.getElementById("form").onsubmit = function() { //when form is submitted, wait for a callba ...
-
我喜欢@ inflagranti的想法 - 所以,没有声称实用程序,这里是一个for-each模板,迭代所有东西。 它使用来自漂亮的打印机的is_container特性,我不在这里复制。 更新:现在已完全解决了裸值类型和对值类型的问题。 更新2:简化了实现类,感谢@Luc Danton。 #include
#include "prettyprint.hpp" using namespace pretty_print; // for "is_container" trait ... -
此代码中的地图大小(Size of Map in this code)[2022-01-02]
为什么这张地图3的大小? 线条 iss.str(line); iss >> word; word = fn1(word); mp[word] += 1; 只抓住一行的第一个单词并将其添加到地图中。 如果查看文本文件的第一个单词,则只有三个唯一单词。 我以为它会是14,计算文本文件中的每个单词。 尝试这个: int main () { mapmp; string line, word; ifstream f_in("text.txt") ... -
为什么地图大小返回0(Why does the map size returns 0)[2022-07-16]
你的getA方法正在返回a的临时副本 ,因此你对setMap的调用正在修改该副本,而不是原始副本。 解决这个问题的一种方法是让getA返回一个引用或指向a的引用 Your getA method is returning a temporary copy of a, so your call to setMap is modifying that copy, not the original. One way to fix this would be to have getA return a refere ... -
按大小排序地图(Sorting map by size)[2022-10-13]
你没有/不能对地图进行排序。 它们根据模板参数的可选第三个参数按键自动排序,模板参数是一个函数对象类,用于比较两个元素以确定哪个元素应该首先出现。 (如果第一个应该在第二个之前,它应该返回true,否则返回false) 所以你可以使用这样的东西: struct myCompare { bool operator() const (const map& lhs, const map & rhs) { return lhs.size() < ... -
地图中的圆圈(大小可扩展)(Circle in map (size scalable))[2022-03-07]
Leaflet中有两种圆圈: L.Circle和L.CircleMarker 。 L.Circle具有以米为单位指定的半径 ,而L.CircleMarker具有以像素为单位指定的半径 。 你的问题还不完全清楚(你的意思是“总是有相同的尺寸”吗?米还是像素?); 但我想你想用L.CircleMarker而不是L.Circle 。 There are two kinds of circles in Leaflet: L.Circle and L.CircleMarker. L.Circle has a radi ... -
来自代码的游戏地图(Game map from Code)[2021-06-12]
我会以代码形式存储游戏地图。 每个节点代表一个国家/城市,每条边代表邻接。 一旦你有这样的地图,我相信你可以在网上找到许多有关人工智能(寻路,策略等)的资源。 如果您希望能够在程序中构建地图图像,请考虑为每个节点添加(x,y)坐标和图像。 这样,您可以在给定坐标处显示所有图像以建立地图视图。 I'd store a game map in code as a graph. Each node would represent a country/city and each edge would represe ... -
您的地图是方形大小,大多数设备都是矩形大小,因此您需要将地图保持在屏幕中心,无论是使用纵向还是横向模式。 public class TileTest extends ApplicationAdapter { ExtendViewport extendViewport; OrthogonalTiledMapRenderer mapRenderer; OrthographicCamera camera; float worldWidth,worldHeight; @O ...
-
我不太确定你想要什么,但是当你添加scale_x_continuous和scale_y_continuous时,你可以使映射区域变小并“放大”到美国。 如果您对映射感兴趣,我建议您查看tmap( https://cran.r-project.org/web/packages/tmap/tmap.pdf )。 它也可以生成点图。 airports <- read.csv("http://bl.ocks.org/mbostock/raw/7608400/airports.csv", stringsAsFacto ...