拼凑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中的乐观锁与悲观锁

    《数据库面试必备之MySQL中的乐观锁与悲观锁》:本文主要介绍数据库面试必备之MySQL中乐观锁与悲观锁的相关资料,乐观锁适用于读多写少的场景,通过版本号检查避免冲突,而悲观锁适用于写多读少且对数... 目录一、引言二、乐观锁(一)原理(二)应用场景(三)示例代码三、悲观锁(一)原理(二)应用场景(三)示例

    SQL表间关联查询实例详解

    《SQL表间关联查询实例详解》本文主要讲解SQL语句中常用的表间关联查询方式,包括:左连接(leftjoin)、右连接(rightjoin)、全连接(fulljoin)、内连接(innerjoin)、... 目录简介样例准备左外连接右外连接全外连接内连接交叉连接自然连接简介本文主要讲解SQL语句中常用的表

    SQL server配置管理器找不到如何打开它

    《SQLserver配置管理器找不到如何打开它》最近遇到了SQLserver配置管理器打不开的问题,尝试在开始菜单栏搜SQLServerManager无果,于是将自己找到的方法总结分享给大家,对SQ... 目录方法一:桌面图标进入方法二:运行窗口进入方法三:查找文件路径方法四:检查 SQL Server 安

    MySQL 中的 LIMIT 语句及基本用法

    《MySQL中的LIMIT语句及基本用法》LIMIT语句用于限制查询返回的行数,常用于分页查询或取部分数据,提高查询效率,:本文主要介绍MySQL中的LIMIT语句,需要的朋友可以参考下... 目录mysql 中的 LIMIT 语句1. LIMIT 语法2. LIMIT 基本用法(1) 获取前 N 行数据(

    MySQL 分区与分库分表策略应用小结

    《MySQL分区与分库分表策略应用小结》在大数据量、复杂查询和高并发的应用场景下,单一数据库往往难以满足性能和扩展性的要求,本文将详细介绍这两种策略的基本概念、实现方法及优缺点,并通过实际案例展示如... 目录mysql 分区与分库分表策略1. 数据库水平拆分的背景2. MySQL 分区策略2.1 分区概念

    MySQL高级查询之JOIN、子查询、窗口函数实际案例

    《MySQL高级查询之JOIN、子查询、窗口函数实际案例》:本文主要介绍MySQL高级查询之JOIN、子查询、窗口函数实际案例的相关资料,JOIN用于多表关联查询,子查询用于数据筛选和过滤,窗口函... 目录前言1. JOIN(连接查询)1.1 内连接(INNER JOIN)1.2 左连接(LEFT JOI

    MySQL 中查询 VARCHAR 类型 JSON 数据的问题记录

    《MySQL中查询VARCHAR类型JSON数据的问题记录》在数据库设计中,有时我们会将JSON数据存储在VARCHAR或TEXT类型字段中,本文将详细介绍如何在MySQL中有效查询存储为V... 目录一、问题背景二、mysql jsON 函数2.1 常用 JSON 函数三、查询示例3.1 基本查询3.2

    MySQL中动态生成SQL语句去掉所有字段的空格的操作方法

    《MySQL中动态生成SQL语句去掉所有字段的空格的操作方法》在数据库管理过程中,我们常常会遇到需要对表中字段进行清洗和整理的情况,本文将详细介绍如何在MySQL中动态生成SQL语句来去掉所有字段的空... 目录在mysql中动态生成SQL语句去掉所有字段的空格准备工作原理分析动态生成SQL语句在MySQL

    MySQL中FIND_IN_SET函数与INSTR函数用法解析

    《MySQL中FIND_IN_SET函数与INSTR函数用法解析》:本文主要介绍MySQL中FIND_IN_SET函数与INSTR函数用法解析,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一... 目录一、功能定义与语法1、FIND_IN_SET函数2、INSTR函数二、本质区别对比三、实际场景案例分

    MySQL中的交叉连接、自然连接和内连接查询详解

    《MySQL中的交叉连接、自然连接和内连接查询详解》:本文主要介绍MySQL中的交叉连接、自然连接和内连接查询,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、引入二、交php叉连接(cross join)三、自然连接(naturalandroid join)四