data-visualization

creating standalone exe using pyinstaller with mayavi import

倖福魔咒の 提交于 2019-11-28 02:08:51
问题 I have a program that helps visualize some data in 3D by plotting a surface and a cloud of points to see how they relate to the surface. For the visualization I am using mayavi since it was easy to set up and does a better job than matplotlib in 3D. The program works great when I run it in my python environment and makes beautiful visualizations. However, I need to distribute this to a few people who don't have Python and would prefer not to have to install python and all the add-ins on each

ggplot2 log transformation for data and scales

瘦欲@ 提交于 2019-11-28 02:07:53
问题 This is a follow-up to my previous question Integrating ggplot2 with user-defined stat_function(), which I've answered myself yesterday. My current problem is that, in the following reproducible example, lines, which are supposed to plot components of the data values' mixture distribution , neither appear in the expected places, nor they're of expected shape, as shown below (see the red lines at y=0 in the second figure). Complete reproducible example : library(ggplot2) library(scales)

Filling under the a curve with ggplot graphs

余生颓废 提交于 2019-11-28 00:26:28
I would like to create a graph with the normal function from x=-2 to x=2 filled under the curve from -2 to 0. I've tried with ggplot2 qplot(c(-2, 2), stat="function", fun=dnorm, geom="line") + + geom_area(aes(xlim=c(-2,0)),stat="function", fun=dnorm) But I get this graph completely filled instead (the black colour) How can I get a plot filled only from -2 to 0? Other options or packages are welcome. I've also tried with only one command with ggplot and filled option but I can't get it either. I know some people does it using polygons but the result is not so soft and nice. PD: I repeat, the

Align multiple ggplot2 plots with grid

放肆的年华 提交于 2019-11-27 22:55:29
Context I want to plot two ggplot2 on the same page with the same legend. http://code.google.com/p/gridextra/wiki/arrangeGrob discribes, how to do this. This already looks good. But... In my example I have two plots with the same x-axis and different y-axis. When the range of the the y-axis is at least 10 times higher than of the other plot (e.g. 10000 instead of 1000), ggplot2 (or grid?) does not align the plots correct (see Output below). Question How do I also align the left side of the plot, using two different y-axis? Example Code x = c(1, 2) y = c(10, 1000) data1 = data.frame(x,y) p1 <-

Visualization of 3D-numpy-array frame by frame

余生颓废 提交于 2019-11-27 22:34:13
# -*- coding: utf-8 -*- """ slider 3D numpy array """ import numpy import pylab from matplotlib.widgets import Slider data = numpy.random.rand(100,256,256) #3d-array with 100 frames 256x256 ax = pylab.subplot(111) pylab.subplots_adjust(left=0.25, bottom=0.25) frame = 0 l = pylab.imshow(data[frame,:,:]) #shows 256x256 image, i.e. 0th frame axcolor = 'lightgoldenrodyellow' axframe = pylab.axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor) sframe = Slider(axframe, 'Frame', 0, 100, valinit=0) def update(val): frame = numpy.around(sframe.val) pylab.subplot(111) pylab.subplots_adjust(left=0.25, bottom=0

How to order bars in faceted ggplot2 bar chart

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 22:26:59
If I want to order the bars in a ggplot2 barchart from largest to smallest, then I'd usually update the factor levels of the bar category, like so one_group <- data.frame( height = runif(5), category = gl(5, 1) ) o <- order(one_group$height, decreasing = TRUE) one_group$category <- factor(one_group$category, levels = one_group$category[o]) p_one_group <- ggplot(one_group, aes(category, height)) + geom_bar(stat = "identity") p_one_group If have have several groups of barcharts that I'd like in different facets, with each facet having bars ordered from largest to smallest (and different x-axes)

How to show matrix values on Levelplot

拥有回忆 提交于 2019-11-27 20:56:10
I have a matrix data here , and I visualized it with levelplot . The Plot is placed below. But I just couldn't put the values into the plot, I mean I read this question , but still couldn't figure it out. How can I do that ? Thanks. The problem with the code in the answer you linked to is that it only works when the objects in the levelplot's formula are named x , y , and z . Here is an example that uses a more standard idiom for processing the arguments passed in to the custom panel function and so becomes more generally applicable: library("lattice") ## Example data x <- seq(pi/4, 5*pi,

How can I generate ascii “graphical output” from R?

主宰稳场 提交于 2019-11-27 20:03:55
I believe R can generate stem-and-leaf for ascii histograms , and scatter plots using this code from Matt Shotwell . Can it also generate ASCII based line graphs , like this from GNUPlot ? You should look at the fairly recent txtplot package. Currently, it includes scatterplot, line plot, density plot, acf, and bar chart. From the online help, > txtplot(cars[,1], cars[,2]) +----+------------+------------+-----------+------------+--+ 120 + * + | | 100 + + | * * | 80 + * * + | * * * | 60 + * * + | * * * * * | 40 + * * * * * + | * * * * * * * | 20 + * * * * * * * + | * * * * | | * * * | 0 +----+-

Arranging arrows between points nicely in ggplot2

浪尽此生 提交于 2019-11-27 18:49:51
问题 (note - this is the same piece of work as using multiple size scales in a ggplot, but I'm asking a different question) I'm trying to construct a plot which shows transitions from one class to another. I want to have circles representing each class, and arrows from one class to another representing transitions. I'm using geom_segment with arrow() to draw the arrows. Is there any way to: make the arrows stop before they reach the circles adjust the position so that if there is an arrow in both

Animated sorted bar chart with bars overtaking each other

感情迁移 提交于 2019-11-27 17:28:18
How would you go at reproducing this chart from Jaime Albella in R ? See the animation on visualcapitalist.com or on twitter (giving several references in case one breaks). I'm tagging this as ggplot2 and gganimate but anything that can be produced from R is relevant. data (thanks to https://github.com/datasets/gdp ) gdp <- read.csv("https://raw.github.com/datasets/gdp/master/data/gdp.csv") # remove irrelevant aggregated values words <- scan( text="world income only total dividend asia euro america africa oecd", what= character()) pattern <- paste0("(",words,")",collapse="|") gdp <- subset(gdp