简体   繁体   English

如何制作可视化草图? R或Pyhon中有什么程序或package?

[英]How to make visualization sketches? What program or package in R or Pyhon is there?

Some years ago this destiny plots were posted.几年前,这个命运情节被张贴了。 Now i need to create similar sketches, does anyone know how these were created?现在我需要创建类似的草图,有人知道这些是如何创建的吗? and what technology would be the best to make something similar?什么技术最适合制作类似的东西?

在此处输入图像描述

This graph was originally posted here...该图最初发布在此处...

How to use 'facet' to create multiple density plot in GGPLOT 如何使用'facet'在GGPLOT中创建多密度plot

Thanks!谢谢!

You can use ggplot facets您可以使用ggplot 方面

library("tidyverse")
data = iris %>% gather(key, value, -Species)
data %>% 
   ggplot(aes(x = value, color = Species)) + 
   geom_density() + 
   facet_wrap(key ~ .)

There is this matplotlib method in python xkcd() which is intended to give plots that sckechy look.在 python xkcd()中有这个 matplotlib 方法,它的目的是让绘图看起来很奇怪。 It will give that kind of handmade look to any of your matplotlib plots.它将为您的任何 matplotlib 地块提供那种手工制作的外观。

I am not sure wether you asked for this, but I felt creative anyways:我不确定你是否要求这样做,但无论如何我觉得很有创意:

# Load libraries
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats

# Set style and an auxiliar list
plt.style.use('bmh')
figs = []

# Initialise figure and let no space between subplots 
f = plt.figure(figsize = (15,15))
f.subplots_adjust(hspace=0, wspace=0)

# Set the main plot axis labels as text boxes
f.text(0.5, 0.04, r'log2(u)', ha='center', va='center', fontsize=50, color = 'firebrick')
f.text(0.06, 0.5, 'Density', ha='center', va='center', rotation='vertical', fontsize=50, color = 'firebrick')

#Add some magic
plt.xkcd(scale=5, length=800)

# For each plot
for i in range(4):

    plt.subplot(2,2,i+1)
    # Remove internal axis labels
    if i in [0,1]:
        plt.xticks([], [])
    if i in [1,3]:
        plt.yticks([], [])    

    # Set figure captions   
    difs = [r'$W_c - W_n$', r'$X_c - X_n$', r'$Y_c - Y_n$',r'$Z_c - Z_n$']    
    plt.text(0,0,difs[i], fontsize=30, ha = 'center',bbox = dict(facecolor='white', alpha=0.6, edgecolor='red'))

    # generate a couple of gaussians to plot with random mu and sigma
    x = np.linspace(-5,5, 100)
    sigma = (np.random.rand()+0.5)
    mu1 = np.random.choice([-2,-1,0,1,2])
    mu2 = mu1
    while mu2 == mu1:
        mu1 = np.random.choice([-2,-1,0,1,2])
    x1 = stats.norm(mu1,sigma).pdf(x)
    x2 = stats.norm(mu2,sigma).pdf(x)

    # We generate the fill plots 
    a = plt.fill(x, x1, alpha = 0.3,label='C')
    b = plt.fill(x, x2, alpha = 0.3,label='N', color = 'coral')
    plt.xlim(-6,6)
    #get the figures to use them for the legend
    figs.extend([a,b])


# Set the main legend
L=f.legend(figs[0:2],loc='upper center',
          ncol=2, fancybox=True, shadow=True, fontsize = 40)

L.get_texts()[0].set_text('CANCER (c)')
L.get_texts()[1].set_text('NORMAL (n)')

plt.show()

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM