拼凑sql_R中的拼凑包

2023-11-10 03:10
文章标签 sql database 拼凑

本文主要是介绍拼凑sql_R中的拼凑包,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

拼凑sql

A Video Form of This Article
本文的视频形式

Patchwork is a package for the R programming language that simplifies data visualization layouts through a simple math-like syntax.

Patchwork是R编程语言的软件包,可通过类似于数学的简单语法简化数据可视化布局。

Image for post
The Patchwork Hex Sticker
拼布六角贴纸

The Composer of ggplots

ggplots的作曲家

With Patchwork the task of combining and organizing ggplots is very easy and can produce ornate visualizations with simple code.

使用Patchwork ,组合和组织ggplots的任务非常容易,并且可以使用简单的代码产生华丽的可视化效果。

All charts here are made with sample data sets and are just used for example purposes.

这里的所有图表都是用示例数据集制作的,仅用于示例目的。

简单图表组合 (Simple Chart Combinations)

垂直堆叠的图表 (Vertically Stacked Charts)

If i wanted to take a couple charts of mind and compare them next to each other either one above the other it may look something like this:

如果我想拍几张思维图,然后将它们彼此比对,则可能看起来像这样:

Image for post
An Example of Code For a Top and Bottom Chart Combo With Patchwork
拼凑而成的顶部和底部图表组合的代码示例

Looking at this code what we do is create 2 ggplots and assign each to their own variable, top and bottom respectively.

看这段代码,我们要做的是创建2个ggplots,并将每个ggplots分别分配给它们自己的变量topbottom

Conveniently named we can see where each is going to be placed in the final visual.

方便命名,我们可以看到每个元素在最终视觉效果中的放置位置。

The simple Patchwork syntax is finding those 2 variables at the bottom and with a simple division sign saying that top should be divided by bottom.

简单的Patchwork语法是在底部找到这两个变量,并带有一个简单的除号,表示top应除以bottom

The syntax is super transparent and intuitive with what it will do with the plots and how you might structure more advanced combinations later on. For now, the stacked visualization will look like

该语法具有极高的透明度和直观性,可用于处理图以及以后如何构造更高级的组合。 现在,堆叠的可视化效果看起来像

Image for post
Top and Bottom Chart Stacking
顶部和底部图表堆叠

水平堆放 (Horizontal Stacking)

If you wanted to stack your plots horizontally its as simple as adding them together:

如果您想水平堆叠地图,就像将它们加在一起一样简单:

Image for post
An Example of Code For a Left and Right Chart Combo With Patchwork
带有拼凑而成的左右图表组合的代码示例

With the + operator you can add charts together flowing from left to right and we show this with the above defined variables conveniently named left and right:

使用+运算符,您可以将图表从左到右加在一起,并使用方便地命名为leftright的上述定义的变量进行显示:

Image for post
Left and Right Chart Stacking
左右图表堆叠

It is also useful to know that using the | pipe operator you can equally divide the sections of the final aggregate visual. So if i ran this code:

知道使用|是非常有用的| 管道运算符,您可以平均划分最终聚合视觉的各个部分。 因此,如果我运行此代码:

Image for post
Usage of the Pipe Operator |
管道操作员的用法|

My output would actually look like a 50/25/25 split between the charts:

我的输出实际上看起来像图表之间的50/25/25分割:

Image for post
The Pipe Operator Evenly Divides Space
管道操作员平均划分空间

溢出和定义网格 (Overflowing and Defining The Grid)

So that is a quick way of putting some visualizations together, what are some more elaborate uses of Patchwork and some of its behavior?

因此,这是将某些可视化组合在一起的快速方法,Patchwork的一些更精细的用法及其行为是什么?

If we add a bunch of charts together with the + operator would it just squeeze the plots together until there’s no room left? We now know that the | will evenly divide available space between the plots, so the more we add the evenly divided space will get more cramped over time. With that known what does adding a lot of plots together achieve?

如果我们将一堆图表与+运算符一起添加,会不会只是将图表挤压在一起,直到没有剩余空间了? 我们现在知道| 会在地块之间平均分配可用空间,因此,随着时间的推移,我们添加的均分空间越多,局限性就会越来越大。 有了这些已知的知识,将很多地块加在一起就能达到什么目的?

Image for post
Adding a Lot of Plots Together
一起添加很多图

So Patchwork will try to keep the plots in a square grid shaped combination with the usage of + so if we have 4 plots we should expect a 2x2 grid square combo plot:

因此,Patchwork将尝试使用+将地块保持在正方形网格形状的组合中,因此,如果我们有4个地块,我们应该期望2x2网格正方形组合地块:

Image for post
2x2 Grid Overflow Plot
2x2网格溢出图

This is helpful so that at least with minimal tampering everything is somewhat visible and less squished than if we used the | to combine the plots.

这很有用,因此与我们使用|相比,至少可以以最小程度的篡改来使所有内容都稍微可见一些,并且压缩起来更少| 合并地块。

You can imagine this grid behavior as plots moving into available slots in an assembly line fashion. The first row (slots 1 and 2) must be filled before flowing down to Row 2 to fill slots 3 and 4.

您可以想象这种网格行为是随着绘图以装配线方式移动到可用插槽中。 必须先填充第一行(插槽1和2),然后向下流入第2行以填充插槽3和4。

Lets say you what to redefine the dimensions of your grid so that you have 3 rows, and 2 columns (a 3x2 grid) and you want to fill the grid by columns not rows. You can imagine the assembly line filling in your grid from top to bottom slot 1, 2, then 3, and finally the top slot of column 2 for the 4th plot.

假设您要重新定义网格尺寸的内容,以便拥有3行和2列(3x2网格),并且希望按列而非行填充网格。 您可以想象装配线从第1排,第2排,第3排,第3排,最后是第4列的第2列的顶部排填充到网格中。

How do we achieve this with Patchwork syntax?

我们如何使用Patchwork语法实现这一目标?

Image for post
Overflow Grid Top to Bottom With 3 Rows
3行从上到下的溢出网格

What we’re saying is add + all the plots together and overflow the grid, but with plot_layout we define with nrow that we want the grid to have 3 rows, and byrow is asking the question “Should i fill each row first before moving down to the next?” and we’re saying No, Fill each column first then move to the next:

我们要说的是增加+所有的情节一起溢出电网,但plot_layout我们有定义nrow我们想要的电网有3排,并byrow在问这个问题:“ 我应该向下移动之前,首先要填写每一行到下一个? ”,我们说的是“ 否” ,请先填充每一列,然后再移至下一列:

Image for post
Custom Grid Layout 3x2 with Vertical Flowing
具有垂直流动的自定义网格布局3x2

堆叠与包装 (Stacking and Packing)

Overflowing the grid is useful but still, you say you want more granular control of the layout? Say no more, we can combine multiple operators to achieve this.

网格的溢出很有用,但您仍然说要对布局进行更精细的控制吗? 无需多说,我们可以合并多个运算符来实现此目的。

Image for post
Some Layout Magic
一些布局魔术

So what is going on here? You might be able to guess what this might look like by now, but just in case lets read it from inside out.

那么这是怎么回事? 您也许能够猜测到现在的样子,但是以防万一,让我们从内而外阅读它。

  • We’re saying take the top chart and place the bottom chart below it in a vertically stacked combo

    我们是说拿top图表,然后将bottom图表放在其bottom的垂直堆叠组合中

  • Then we have a combination of the left chart taking up the left half and the combo of top and bottom taking up the right half

    然后,我们将left占据了左半部分,而topbottom组合占据了右半部分

  • And finally we take that 3 part combo chart and put the right chart underneath it to finish it off.

    最后,我们采用该三部分组合图并将right图放在其下以完成该过程。

You can see how with some simple order of operations (we all remember the PEMDAS acronym from algebra right?) we can easily and logically control the layout of the plots. Lets see the fruits of our labor:

您可以看到如何用一些简单的操作顺序( 我们都记得 代数中 PEMDAS 缩写吗? )可以轻松而合理地控制图的布局。 让我们看看我们劳动的成果:

Image for post
The Stacking and Packing Chart Output
堆积和包装图输出

This isn’t the prettiest example but you can see by this example the power and flexibility that Patchwork give you with your layouts.

这不是最漂亮的示例,但是您可以通过此示例看到Patchwork为您的布局提供的功能和灵活性。

HOWEVER! We left one important thing out, we need to name our Franken-Plot, but with so many pieces involved in this…. Patchwork Plot…. Sorry, I’ll stop. With so many pieces how do we appropriately name the whole aggregate visual?

然而! 我们遗漏了一件重要的事情,我们需要命名弗兰肯情节,但其中涉及很多方面……。 拼布图...。 对不起,我停一下。 有这么多片段,我们如何恰当地命名整体视觉效果?

By adding one more thing:

通过添加另一件事:

Image for post
plot_annotation to Name Your New Patchwork Child
plot_annotation为您的新拼布孩子命名

plot_annotation will let us appropriately title the whole aggregate visualization in the top left:

plot_annotation将让我们在左上方适当地plot_annotation整个聚合可视化:

Image for post
Our Plot Is Done and Ready For The Big Time
我们的情节已经做好,准备迎接大时代

Ugly visualizations aside you can see the gold of the Patchwork package shine through and the value it could provide you in your work with R.

除了丑陋的可视化效果之外,您还可以看到Patchwork程序包的金色光芒,以及它在使用R时可以为您提供的价值。

运营商及其工作概述 (Quick Summary of The Operators and What They Do)

A Quick Recap of the various operators and functions covered:

所涵盖的各种运算符和功能的快速回顾:

  • + Add plots together, defaults left to right, overflows the grid

    +将图加在一起,默认从左到右,使网格溢出

  • / Divide plots, Put Left hand side on top of right hand side

    /划分图,将左手边放在右手边的顶部

  • | Evenly separate plots into equal sized portions based on how many | are used: one | two | three produces 3 x 33.33% slots

    | 根据多少|将地块平均分成相等大小的部分 使用: one | two | three one | two | three one | two | three产生3 x 33.33%的插槽

  • ( & ) are used for order of operations “Do This First then the stuff outside of us”

    ()用于操作顺序“先执行此操作,然后进行外部操作”

谢谢! (Thanks!)

码? (Code?)

If you would like all the example code used in the video / this article you can grab it here:

如果您想要视频/本文中使用的所有示例代码,可以在这里获取:

翻译自: https://medium.com/analytics-vidhya/the-patchwork-package-in-r-9468e4a7cd29

拼凑sql


http://www.taodudu.cc/news/show-8200457.html

相关文章:

  • 蓝桥杯选拔赛:整数拼凑问题
  • 【学会放下
  • 三十五、新人成才之路《结语 放下的快乐:从简单到复杂,再到简单》
  • 一切都放下吧
  • 学会放下,让快乐离自己近一些
  • 人生需要放下的八样东西
  • 人生需要放下八样东西
  • 人生需要放下六样东西
  • 成熟,让自己如何放下
  • 放下烦恼,快乐其实很简单
  • 学会放下
  • 人生如何才能快乐
  • 放下手机吧:实验表明花20分钟思考和上网冲浪同样快乐
  • 放下即是快乐
  • 管理感悟:放下就是快乐 (转)
  • 《放下就是快乐》之体会二
  • 《放下就是快乐》之体会一
  • 放下就是快乐
  • 愈放下,愈快乐
  • 《放下就是快乐》之世间真爱
  • 管理感悟:放下就是快乐
  • echarts数据更新图表不跟新问题
  • 梅根和哈里:当心元宇宙
  • 空间几何 开源_开源为所有人提供了空间
  • 涉性侵人员就业被限制,中国版《梅根法案》何时到来?
  • 深富策略:市场遇阻消化 热点高速轮转
  • 少数人带动多数人
  • 大数据分析平台洱源县_洱源:引入“发财树”  群众奔富路
  • 深富策略:上证指数回升 这一信号需要重视!
  • 深富策略:上证指数收复3600市场缩量信号需警惕
  • 这篇关于拼凑sql_R中的拼凑包的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



    http://www.chinasem.cn/article/380075

    相关文章

    MySQL中EXISTS与IN用法使用与对比分析

    《MySQL中EXISTS与IN用法使用与对比分析》在MySQL中,EXISTS和IN都用于子查询中根据另一个查询的结果来过滤主查询的记录,本文将基于工作原理、效率和应用场景进行全面对比... 目录一、基本用法详解1. IN 运算符2. EXISTS 运算符二、EXISTS 与 IN 的选择策略三、性能对比

    MySQL常用字符串函数示例和场景介绍

    《MySQL常用字符串函数示例和场景介绍》MySQL提供了丰富的字符串函数帮助我们高效地对字符串进行处理、转换和分析,本文我将全面且深入地介绍MySQL常用的字符串函数,并结合具体示例和场景,帮你熟练... 目录一、字符串函数概述1.1 字符串函数的作用1.2 字符串函数分类二、字符串长度与统计函数2.1

    SQL Server跟踪自动统计信息更新实战指南

    《SQLServer跟踪自动统计信息更新实战指南》本文详解SQLServer自动统计信息更新的跟踪方法,推荐使用扩展事件实时捕获更新操作及详细信息,同时结合系统视图快速检查统计信息状态,重点强调修... 目录SQL Server 如何跟踪自动统计信息更新:深入解析与实战指南 核心跟踪方法1️⃣ 利用系统目录

    MySQL 内存使用率常用分析语句

    《MySQL内存使用率常用分析语句》用户整理了MySQL内存占用过高的分析方法,涵盖操作系统层确认及数据库层bufferpool、内存模块差值、线程状态、performance_schema性能数据... 目录一、 OS层二、 DB层1. 全局情况2. 内存占js用详情最近连续遇到mysql内存占用过高导致

    Mysql中设计数据表的过程解析

    《Mysql中设计数据表的过程解析》数据库约束通过NOTNULL、UNIQUE、DEFAULT、主键和外键等规则保障数据完整性,自动校验数据,减少人工错误,提升数据一致性和业务逻辑严谨性,本文介绍My... 目录1.引言2.NOT NULL——制定某列不可以存储NULL值2.UNIQUE——保证某一列的每一

    解密SQL查询语句执行的过程

    《解密SQL查询语句执行的过程》文章讲解了SQL语句的执行流程,涵盖解析、优化、执行三个核心阶段,并介绍执行计划查看方法EXPLAIN,同时提出性能优化技巧如合理使用索引、避免SELECT*、JOIN... 目录1. SQL语句的基本结构2. SQL语句的执行过程3. SQL语句的执行计划4. 常见的性能优

    SQL Server 中的 WITH (NOLOCK) 示例详解

    《SQLServer中的WITH(NOLOCK)示例详解》SQLServer中的WITH(NOLOCK)是一种表提示,等同于READUNCOMMITTED隔离级别,允许查询在不获取共享锁的情... 目录SQL Server 中的 WITH (NOLOCK) 详解一、WITH (NOLOCK) 的本质二、工作

    MySQL 强制使用特定索引的操作

    《MySQL强制使用特定索引的操作》MySQL可通过FORCEINDEX、USEINDEX等语法强制查询使用特定索引,但优化器可能不采纳,需结合EXPLAIN分析执行计划,避免性能下降,注意版本差异... 目录1. 使用FORCE INDEX语法2. 使用USE INDEX语法3. 使用IGNORE IND

    SQL Server安装时候没有中文选项的解决方法

    《SQLServer安装时候没有中文选项的解决方法》用户安装SQLServer时界面全英文,无中文选项,通过修改安装设置中的国家或地区为中文中国,重启安装程序后界面恢复中文,解决了问题,对SQLSe... 你是不是在安装SQL Server时候发现安装界面和别人不同,并且无论如何都没有中文选项?这个问题也

    2025版mysql8.0.41 winx64 手动安装详细教程

    《2025版mysql8.0.41winx64手动安装详细教程》本文指导Windows系统下MySQL安装配置,包含解压、设置环境变量、my.ini配置、初始化密码获取、服务安装与手动启动等步骤,... 目录一、下载安装包二、配置环境变量三、安装配置四、启动 mysql 服务,修改密码一、下载安装包安装地