Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何可视化大容量三维数据_Python_R_Plot_Pandas_Data Visualization - Fatal编程技术网

Python 如何可视化大容量三维数据

Python 如何可视化大容量三维数据,python,r,plot,pandas,data-visualization,Python,R,Plot,Pandas,Data Visualization,我有如下数据集: import numpy as np from pandas import DataFrame mypos = np.random.randint(10, size=(100, 2)) mydata = DataFrame(mypos, columns=['x', 'y']) myres = np.random.rand(100, 1) mydata['res'] = myres res变量是连续的,x和y变量是表示 位置(因此大部分重复), res表示位置对之间的某种关联

我有如下数据集:

import numpy as np
from pandas import DataFrame
mypos = np.random.randint(10, size=(100, 2))
mydata = DataFrame(mypos, columns=['x', 'y'])
myres = np.random.rand(100, 1)
mydata['res'] = myres
res变量是连续的,x和y变量是表示 位置(因此大部分重复), res表示位置对之间的某种关联

我想知道可视化这个数据集的最佳方式是什么? 已经考虑的可能办法:

  • 散点图,通过颜色渐变显示res变量
  • 平行坐标图
  • 第一种方法是当职位数量变大时出现问题, 因为res变量的高值(即我们关心的值)将淹没在一片混乱的海洋中 小点

    第二种方法可能是有希望的,但我很难实现它。 我已经尝试了pandas模块中的parallel_坐标函数, 但它的行为不像我希望的那样。(见此问题:
    )

    我希望这有助于在R中找到解决方案。祝你好运

    # you need this package for the colour palette
    library(RColorBrewer)
    
    # create the random data
    dd <- data.frame(
        x = round(runif(100, 0, 10), 0),
        y = round(runif(100, 0, 10), 0),
        res = runif(100)
    )
    
    # pick the number of colours (granularity of colour scale)
    nColors <- 100 
    
    # create the colour pallete
    cols <-colorRampPalette(colors=c("white","blue"))(nColors)
    
    # get a zScale for the colours
    zScale <- seq(min(dd$res), max(dd$res), length.out = nColors)
    
    # function that returns the nearest colour given a value of res
    findNearestColour <- function(x) {
        colorIndex <- which(abs(zScale - x) == min(abs(zScale - x)))
        return(cols[colorIndex])
    }
    
    # the first plot is the scatterplot
    ### this has problems because points come out on top of eachother
    plot(y ~ x, dd, type = "n")
    for(i in 1:dim(dd)[1]){
        with(dd[i,],
            points(y ~ x, col = findNearestColour(res), pch = 19)
        )
    }
    
    # this is your parallel coordinates plot (a little better)
    plot(1, 1, xlim = c(0, 1), ylim = c(min(dd$x, dd$y), max(dd$x, dd$y)), 
         type = "n", axes = F, ylab = "", xlab = "")
    for(i in 1:dim(dd)[1]){
        with(dd[i,],
            segments(0, x, 1, y, col = findNearestColour(res))
        )
    }
    
    #调色板需要此软件包
    图书馆(RColorBrewer)
    #创建随机数据
    
    dd是否应将其标记为“r”?看起来它更像是Python Q。是的,但我不介意在R中这样做,只要它能完成任务。成对的hexbin绘图?这太“模糊”。
    parcoord
    parallelplot
    在R中对我有用。当有数千行时,使用透明颜色会有所帮助。也许您应该在数据创建已经完成的情况下重新发布。然后是编码问题,而不是“推荐方法问题”