R中演化为新的调色板与evoPalette

2020年6月7日
By

[本文首次发表于R – Daniel Oehm | Gradient Descending,并慷慨解囊,以188bet app]。(您可以在本网页上的内容报告问题金宝搏网址这里)
要共享R-博客内容?188bet app188bet app 如果你有一个博客,或这里如果你不这样做。

What’s that saying? Choice is the enemy of happiness, or something like that. There are so many colour palettes out there, that saying tends to resonate when either choosing one, or creating a new one. So, I started to think about a way I could make this more organic, and came up with the idea for evoPalette.

evoPaletteallows for the discovery and generation of new colour palettes for R. Taking user input it uses an evolutionary algorithm to spawn new palettes with the expectation the colours you like will be combined over time. This can be repeated as many times as needed until you find something that works for you.

有很多颜色的理论,没有选择是微不足道的,因此留下一些这些选择主要是一个算法都会有不同程度的成功。这是交易的最佳实践的乐趣和发现的,但我可以接受的!

简单地说,算法

简单地说,进化算法在3个主要步骤进行操作:

  1. Selection: Each candidate has a measure of fitness and those that reach some threshold survive. In this case parents of the next generation are selected by the user and so fitness is essentially personal preference.
  2. CROSSOVER:儿童从父母双方的基因的随机组合产生了。在这种情况下颜色代表的基因。
  3. 突变:突变以两种方式1)存在对调色板和2)产生一个完全新的颜色的机会每种颜色而异周围局部它的初始值发生。

The process can continue for as long as needed.

安装

您可以安装evoPalette从Github上用下面的命令。

devtools::install_github("doehm/evoPalette")

(It’s only on Git for the moment. We’ll see how it goes.)

入门

To jump straight into it launch the Shiny app with

launch_evo_palette()

To generate the first set of palettes, click‘evolve’。Using the default setting the initial palettes will be randomly drawn from a standard set saved in evoPalette and paletteer.Paletteer包含了一些1700 +调色板的包ages.

选择一个或多个调色板,你喜欢,并认为可以从复选框,然后单击共同努力以及‘evolve’。下一代调色板将被创建。

从复选框选择父母对下一代

随着每一代人,你会发现调色板如何汇聚成根据您的选择了类似的主题,对于各个颜色的一些变化和全新的颜色的机会一起。你喜欢约一个调色板中的功能必须与其他颜色组合,并流经给下金宝搏网址一代的机会。虽然这不能完全保证,因为仍然有在玩一个随机元素,但你会发现,你的作品以及其他组合。所选父调色板显示在边栏中以供参考。

选择调色板的孩子。注意颜色和随机突变的类似的组合。名称是随机生成的。

仅选择单个父是便于产生的微小变化来调整颜色。

Select“实施例:填充审美”to see how the palette works in practice (similarly for‘Example: Colour aesthetic’)。

要保存的调色板,请从复选框所需的面板,然后单击“保存“。会出现一个框给予机会改变随机生成的调色板名称,但是,你为什么要!

调色板现在是从访问palette_box()一旦应用程序被关闭。多种配色可以保存这些被收集在调色板中,只保存一次一个。开始一个新的会话时,所以记得要保存到磁盘的面板框被刷新。

调色板“启发客户保存到调色板框。
palette_box()$instructive_customers [1] "#C7B6C8" "#74B6BA" "#7783C4" "#B56D4E" "#F28E47" "#FCE269"

要重新开始,取消所有调色板,点击‘evolve’。新的调色板是随机选择开始一个新的进程。

调色板是通过使用观察show_palette()

show_palette(palette_box()[ “instructive_customers”])

The continuous scales are simply created from the two colours on the ends and one in the middle (room for improvement).

Control

用户具有通过调节的突变率和变化允许每个颜色在算法的一些控制。选择从菜单下拉的参数。

Click the drop down to access parameters list.
  • Number of colours to generate for each palette. Initial starting palettes with more / fewer colours are coerced to have the desired amount. So, a standard palette with more or fewer than this amount will be slightly different.
  • 调色板的数量在每一位进化。默认值为9。
  • 突变率 - 在调色板中每种颜色都有随机突变的概率等于这个值(默认值P = 0.05)
  • 突变variation – Each colour will vary slightly around it’s original value.
  • Load existing palettes from the global environment. Object should be a list, ideally with names i.e. the same format aspalette_box()
  • Are you feeling lucky? Select for generating palettes from completely random colours.

When you are happy with your selections, click‘evolve’和begin a new process.

The generated colour palettes are easily added to ggplots using the scale functionsscale_fill_evoscale_colour_evo

library(ggplot2) mpg %>% ggplot(aes(x = displ, fill = class)) + geom_histogram() + scale_fill_evo("instructive_customers")

The first palette in the list is used if no name is given. The scales are also parameterised to reverse the palette and switch discrete / continuous.

Evolution isn’t perfect

色彩理论是非常复杂的东西,所以选择一个好的调色板是不容易的,更何况是一个不断发展的。所以,你将有一定的命中和一些失误。这绝对是更好玩看到的你会发现,而不是寻找完美的调色板。说了这么多,你可以发现一些黄金!

There are best practices when choosing a palette for data visualisation depending on the context and what is to be shown. For example people tend to respond to certain colours representing high / low, hot / cold or good / bad, there is also colourblindness considerations. evoPalette won’t necessarily adhere to these ideals.

This is best for generating discrete colour palettes with 4-7 distinct colours. It will help you find colours which are to your liking and generate a palette which is unlikely to already exist. It’s fun to experiment and see what you come up with!

evoPalette palettes

有些我已经创建和初始启动调色板如下所示。有几个是从evoPalette,一些从聚类过程中产生的。上世纪90年代摇滚调色板是从专辑封面创建。对不起,在链条上的爱丽丝增加了一倍

g_evo < -  readRDS(执行。系统( “扩展数据/ palettes.rds”,包= “evoPalette”))MAP2(g_evo $调色板,g_evo $名称,〜show_palette(.X,标题= .Y))%>%wrap_plots(NcoI位= 2)

The postR中演化为新的调色板与evoPaletteappeared first on丹尼尔Oehm| Gradient Descending

To发表评论for the author, please follow the link and comment on their blog:R – Daniel Oehm | Gradient Descending

188bet appR-博客。comoffers每日电子邮件更新金宝搏网址 Rnews and tutorials about金宝搏网址 和许多其他议题。Click here if you're looking to post or find an R/data-science job
要共享R-博客内容?188bet app188bet app 如果你有一个博客,或这里如果你不这样做。



如果你走到这一步,为什么不subscribe for updatesfrom the site? Choose your flavor:电子邮件,推特,1188bet app, orFacebook的。。。

评论被关闭。

Search R-bloggers

Sponsors

Never miss an update!
订阅R-博客188bet app受到
电子邮件与最新的[R帖子。
(您将不会再看到这条消息。)

点击此处关闭(此弹出不会再次出现)