使用Blender将不同的主题应用于数据可视化

A key component in any data visualization is the colors used for the elements in the visualization. From the lines and dots to the data and axis labels, the colors used have a central role in the visualization. Color selection can change the perception of the data or emphasize a particular element in a data visualization. The following describes a simple and quick method to create a mock dashboard to select the right color and theme combination.

任何数据可视化中的关键组成部分是用于可视化中元素的颜色。 从线条和点到数据和轴标签,所使用的颜色在可视化中起着中心作用。 颜色选择可以改变数据的感知或强调数据可视化中的特定元素。 下面介绍一种简单快速的方法来创建模拟仪表板,以选择正确的颜色和主题组合。

Mock data can be created in a variety of ways, it can be a fixed set of preselected numbers or random numbers. An advantage offered by random numbers is the variability and the different combination of data that can be created. That variability can be helpful to detect extreme data cases or particular problems with the visualization design. Particularly, NumPy offers a function to create random numbers in the range [0,1]. Using that functionality a set of three different mock data sets are created for a bar plot, a scatter plot, and a line plot.

模拟数据可以通过多种方式创建,它可以是一组固定的预选数字或随机数。 随机数提供的一个优势是可变性和可以创建的数据的不同组合。 这种可变性有助于检测极端数据案例或可视化设计中的特定问题。 特别是,NumPy提供了创建范围为[0,1]的随机数的功能。 使用该功能,可以为条形图,散点图和折线图创建三个不同的模拟数据集。

###############################################################################
# Data
###############################################################################


maxData=100


barPlotData=np.random.random(int(maxData/10))
barPlotTicks=["Class" +str(val) for val in range(int(maxData/10))]


xScatterData=np.random.random(maxData)
yScatterData=np.random.randn(maxData)


xLineData=np.arange(int(maxData/8))
yLineData=np.random.random(int(maxData/8))

The bar plot is created by adding a series of extruded cubes and a label at the bottom of each cube. All the added geometries are joined in two sets, a data set, that contains the bars and a tick set, that contains the label for each bar. Each group contains only one geometry object to simplify the number of objects in the scene.

条形图是通过在每个立方体的底部添加一系列挤出的立方体和标签来创建的。 所有添加的几何图形都分为两组,一个是数据集,其中包含条形图;另一个是滴答集,其中包含每个条形图的标签。 每个组仅包含一个几何对象,以简化场景中的对象数量。

def MakeBarPlot(BarsData,ticksLabels,PlotName,location,extend):
    """
    Parameters
    ----------
    BarsData : list,array
        Data for the bar plot.
    ticksLabels : list,array
        list with the tick labels for the x axis in the bar plot.
    PlotName : string
        name for the geometries created for the plot.
    location : tuple
        Global location for the bar plot.
    extend : float
        extend of the bar plot.

    Returns
    -------
    barNames : list
        list with the bars geometry names.
    tickNames : lits
        list with the ticks geometry names..

    """
    nBars=len(BarsData)
    maxVal=max(BarsData)
    NormData=[val/maxVal for val in BarsData]
    step=(2*extend)/(nBars-1)
    xBarLocations=[-(extend)+(k*step)+location[0] for k in range(nBars)]
    barGeometryNames=MakeObjectNames(PlotName+"Bar",nBars)
    tickGeometryNames=MakeObjectNames(PlotName+"Tick",nBars)
    padding=extend/20


    for k in range(nBars):
        currentBarHeight=(extend/2)*NormData[k]
        currentBarLocation=currentBarHeight-extend+location[1]
   
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值