Here is one solution to what I think you are after. Generate data. myData <- mapply(rnorm, 1000, 200, mean=seq(-50,50,0.5)) This is a matrix with 1000 rows (observations) and 201 time points. In each time point the mean of data there shifts gradually from -50 to 50. By 0.5 each time....

Here is an example to do it. import numpy as np import pandas as pd import matplotlib.pyplot as plt # simulate some artificial data x = np.random.randn(1000,) y = 5 * x ** 2 + np.random.randn(1000,) data = pd.DataFrame(0.0, columns=['X', 'Y'], index=np.arange(1000)) data.X = x data.Y = y # now...

Shamefully taken from Ari's post on gis.stackexchange.com. See the link for pictures. There are more examples here. library(sp) Srs1 = Polygons(list(Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))), "s1") Srs2 = Polygons(list(Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))), "s2") SpDF <- SpatialPolygonsDataFrame( SpatialPolygons(list(Srs1,Srs2)), data.frame(z=1:2, row.names=c("s1","s2") ) ) spplot(SpDF, zcol="z") ...

> gsub("\\..*","",deparse(substitute(mydf.mtcars))) [1] "mydf" ...

Question 1 I think you've shown for yourself that the commands are not wholly equivalent and just want some reassurance of this. To do what you want to do - you can pass in projection to the add_subplot() calls that are used 'under the covers' by setting up a dictionary...

You can use sort to sort your data. Consider the following data file which I have generated consistent with your time format: 2000-12-21 12:32:05 1 2001-11-21 12:32:05 2 2000-12-20 12:32:05 3 2000-12-20 12:32:04 4 Typing sort data.txt will yield the correct ordering: 2000-12-20 12:32:04 4 2000-12-20 12:32:05 3 2000-12-21 12:32:05...

Hi you use the wrong JS library, it's morris, not polycharts, try : # ui.R library(shiny) library(rCharts) ui<-fluidPage( headerPanel("Economics data with rCharts"), mainPanel( showOutput("myChart","morris") ) ) # server.R library(shiny) library(rCharts) require(datasets) server<-function(input,output){ output$myChart<-renderChart2({ data(economics, package = 'ggplot2') econ <- transform(economics, date = as.character(date)) m1 <- mPlot(x = 'date', y =...

You are passing a list when ploting. Remember cdr returns a list and not an element (like car does). You want to use cadr. #lang racket (require plot) (define list-sqr-graph (lambda (lst) (cond [(null? lst) (plot (function sqr 0 0))] [(<= (car lst) 0) (list-sqr-graph (cdr lst))] [(not (equal? (length...

Use scatter3: N_colors = 64; colormap(cool(N_colors)); # point positions (your data(:, 1:3)) [x, y, z] = peaks (20); # this are the color indexes in the colormap (your data(:, 4)) c_index = fix(rand(size(x)) * N_colors); marker_size = 8; scatter3(x(:), y(:), z(:), marker_size, c_index(:)) ...

r,plot,ggplot2,rstudio,boxplot

ggplot2 requires that your data to be plotted on the y-axis are all in one column. Here is an example: set.seed(1) df <- data.frame( value = runif(810,0,6), group = 1:9 ) df library(ggplot2) ggplot(df, aes(factor(group), value)) + geom_boxplot() + coord_cartesian(ylim = c(0,6) The ylim(0,6) sets the y-axis to be between...

In Matlab, you can plot something using plot(xArray, yArray);. If you want to shift the plot along the x axis, you could use plot(xArray + amountToShift, yArray);. As I believe shifting is not what your real problem is, I've added an example where data gets plotted in the way you...

Try one of this: barplot(as.matrix(ab_group),legend.text = TRUE,col=1:nrow(ab_group)) barplot(as.matrix(ab_group),legend.text = TRUE, beside=T,col=1:nrow(ab_group)) barplot(as.matrix(t(ab_group)),legend.text = TRUE,col=1:ncol(ab_group)) barplot(as.matrix(t(ab_group)),legend.text = TRUE, beside=T,col=1:ncol(ab_group)) The last one is here: ...

If you wish to transform your year to factor, on the lines of the code below: # Transform the data to long library(reshape2) df <- melt(data = df, na.rm = FALSE, id.vars = "Year") df$Year <- as.factor(df$Year) # Chart require(ggplot2) ggplot(df, aes(Year, value)) + geom_area(aes(colour = variable, fill= variable), position...

Yes, that is a bug, see #1596 columnhead(x) does not work for x>=1000. As workaround you can extract the first line e.g. with the command line tool head, and access the content with word: header = system('head -n 1 file') plot 'file' using 1:1000 skip 1 title word(header, 1000) ...

A simple way would be to use layout(): layout(mat=matrix(c(1,1,1,2,3,4), ncol=3, byrow=TRUE)) image(matrix(1:100, nrow=100), main="my wide plot", axes=FALSE) plot(rnorm(120), rnorm(120), main="plot 1") plot(dpois(0:20, lambda=6), type="b", , main="plot 2") x = rnorm(100) y = x+runif(100, 10, 12) plot(x=x, y=y, main="plot 3") (For a nice example of a much more sophisticated layout, see...

matlab,image-processing,plot,histogram

Assuming uint8 precision, each call to imhist will give you a 256 x 1 vector, and so you can concatenate these together into a single 768 x 1 vector. After, call bar with the histc flag. Assuming you have your image stored in im, do this: red = imhist(im(:,:,1)); green...

python,numpy,matplotlib,plot,instance

Since Calculations is a class, this line invokes the implicit constructor: self.myPlotData = file2.Calculations(*user info*) And you should know that the result of a constructor is an instance of the class. Which is exactly why you are getting that type information. If you actually want myPlotData to be an array,...

Same approach just generalized in a for-loop: for (b in c(0.1,0.2))curve(abs(x^2 - b^2),add=TRUE,col='red') ...

python,matplotlib,plot,3d,surface

Even if I agree with the others that meshgrids are not difficult, still I think that a solution is provided by the Mayavi package (check the function surf) from mayavi import mlab mlab.surf(Z) mlab.show()...

javascript,r,plot,statistics,shiny

Answering my own question since, after all, I have found some resources that fit my use case and they seem viable for development. Hopefully it'll come in handy for the comunity later down the road :) After further investigation, I found the name of "pictogram charts" as an alternative way...

seaborn turns the legend frame off by default, if you want to customize how the frame looks, I think you'll need to add frameon=True when you call plt.legend.

See the docs for bar. You can reshape info to 2xN (instead of its current shape 1x2N) and then use a single bar command to plot the 2 series, and it will take care of the spacing. See this image from the docs: If you want to keep doing it...

The strings defined in the legend command are assigned in order of the plots being generated. This means that your first string 'signal1' is assigned to the plot for signal1 and the second string 'signal2' is assigned to the vertical line. You have two possibilities to fix this problem. Execute...

python,numpy,matplotlib,graph,plot

You can use the condition z=='some tag' to index the x and y array Here's an example (based on the code in your previous question) that should do it. Use a set to automate the creation of tags: import csv import datetime as dt import numpy as np import matplotlib.pyplot...

This happens because you specified the x axis scale with scales = list(x = list(at = 5:15)), but you didn't actually change the breakpoints. It happens in the default case as well: the default axis labels are integers, but the default breakpoints are determined programmatically and are not necessarily integers...

There is an answer on the Mathworks website that I think you will find helpful: http://www.mathworks.com/matlabcentral/answers/92565-how-do-i-control-axis-tick-labels-limits-and-axes-tick-locations. Basically what you want to do is manipulate the XTick or XTickLabel attributes of the current axis handle. Lets say I have a plot that spans 100 years from 1900 - 2000. After creating...

The easiest method would be to create another column in your data set with the right conversion. This would also be easier to audit and manipulate. If you insist on changing manually: You cannot simply set the labels directly, as it recycles (I think) the label vector for each facet....

shadedplot.m works very nicely for applications like that. Try this: shadedplot(x, y2, y3, [0.8 0.8 1], [0.8 0.8 1]) hold on plot(x, y1, 'Color', [0.3 0.3 0.8], 'Linewidth', 3) ...

Just feed an entire vector of dates into the xleft and xright parameters, as indexed by z==1. Don't do line shading, it will run a long time, just change the color to grey. Afterwards, plot the time series again over the rectangles: plot(date,x, type='l') rect(xleft=date[z==1]-180,xright=date[z==1]+180, ybottom=5, ytop=7.5, col="grey",border=NA) lines(date,x) ...

You need to change the setting in setting file, you can get the current setting file path by following code: import matplotlib as mpl print mpl.matplotlib_fname() if the file is in mpl-data folder, then copy it to user setting folder by following code: import shutil shutil.copy(mpl.matplotlib_fname(), mpl.get_configdir()) then restart you...

As the documentation states fill_between returns a PolyCollection instance. Collections are stored in ax.collections. So ax.collections.pop() should do the trick. However, I think you have to be careful that you remove the right thing, in case there are multiple objects in either ax.lines or ax.collections. You could save a reference...

As rth suggested, define x1 = np.linspace(0, 1, 1000) x2 = np.linspace(0, 1, 100) and then plot raw versus x1, and smooth versus x2: plt.plot(x1, raw) plt.plot(x2, smooth) np.linspace(0, 1, N) returns an array of length N with equally spaced values from 0 to 1 (inclusive). import numpy as np...

Take this for a starter code : import numpy as np import matplotlib.pyplot as plt from sqlalchemy import create_engine import _mssql fig = plt.figure() ax = fig.add_subplot(111) engine = create_engine('mssql+pymssql://**:[email protected]:1433/AffectV_Test') connection = engine.connect() result = connection.execute('SELECT Campaign_id, SUM(Count) AS Total_Count FROM Impressions GROUP BY Campaign_id') ## the data data =...

This is quite simple; just feed into subplot the locations as a vector. For instance, x = -2*pi:0.01:2*pi; subplot(2,2,[1,3]) plot(x,sin(x)) subplot(2,2,2) plot(x,cos(x)) subplot(2,2,4) plot(x,x.^2) gives: ...

Based on an answer for modifying tick labels I came up with a solution, don't know whether it will work in your case as your code snippet can't be executed in itself. The idea is to force the tick labels to a .5 spacing, then replace every .5 tick with...

plot,list-comprehension,python-3.4,nested-lists

You need to build two new lists. You can do this with list comprehensions: x = [sub[0] for sub in nested_list] y = [sub[2] for sub in nested_list] plt.plot(x,y) Your code tried to access one level of nesting too many (you can only address nested_list[k][0], not nested_list[k][0][0]) or tried to...

python,python-2.7,matplotlib,plot,histogram

As far as I know, matplotlib does not have this function built-in. However, it is easy enough to replicate import numpy as np heights,bins = np.histogram(data,bins=50) heights = heights/sum(heights) plt.bar(bins[:-1],heights,width=(max(bins) - min(bins))/len(bins), color="blue", alpha=0.5) Edit: Here is another approach from a similar question: weights = np.ones_like(data)/len(data) plt.hist(data, bins=50, weights=weights, color="blue",...

OK I figure it out by myself ggplot(data, aes(x=V2, color=V1)) + geom_density(aes(group=V1)) Should be able to do that. However there is two thing I need to make sure first in order to let it run: V1 is a factor V2 is a numerical value The data I got wasn't set...

matlab,multidimensional-array,plot,size,cell

You can specify the axis with pcolor by putting x and y as first arguments: x = 1:2:10; y = 1:5:51; pcolor (x, y, cond); Best...

I found that I can switch the place of the secondary y axis, so the secondary y axis is plotted on the left and the primary on the right: ax2 = ax1.twinx() p1 = ax2.plot(ind, total_facilities, '--bo') p2 = ax1.bar(ind, pdb_facilities, width, color='gray',edgecolor = "none") plt.xlim([-1,len(total_facilities)]) ax2.set_yscale('symlog') ax1.yaxis.tick_right() ax2.yaxis.tick_left() plt.show()...

matlab,image-processing,plot,3d,surface

Setting those values to NaN should do. Here's an example: [x, y] = ndgrid(linspace(-1,1,500)); z = cos(2*pi*(x+y)*2); z(x.^2+y.^2>1) = NaN; %// remove values outside unit circle surf(x,y,z,'edgecolor','none') colorbar view(2) axis equal ...

Your small data set script is largely correct, but with some minor errors. You are missing the if i=='date': continue line. (The source of your 'not comparable' error). In your post, your else line is mis-indented. Possibly (only possibly) you need a call to plt.hold(True) to prevent the creation of...

plot,shiny,reactive-programming,weight

there should be 70*nrow(labelSub()) instead 70*ncol(labelSub()) Thanks to Joe Cheng from shiny discuss group https://groups.google.com/forum/#!topic/shiny-discuss/hW4uw51r1Ak

Instead of using xlabel and ylabel, you may want to go with set label. For example, #!/usr/local/bin/gnuplot datafile='tmp.dat' # file to plot set xlabel " " # no x-label set ylabel " " # no y-label # assuming all plots have same x and y range set xrange [-2:2] set...

Perhaps something like this is what you're after, but this would be easier if you would provide sample data and be more descriptive in the exact question you are asking: library(ggplot2) library(dplyr) library(tidyr) df <- data.frame(id = 1:400, state = state.abb, ind1 = rnorm(400), ind2 = rnorm(400), ind3 = rnorm(400))...

matlab,plot,matlab-figure,figure

Try this out NumTicks = 4; L = get(gca,'XLim'); set(gca,'XTick',linspace(L(1),L(2),NumTicks)) You can easily wrap it in a function if you like....

You can change the XTickLabels property using your own format: set(gca,'XTickLabels',sprintfc('1e%i',0:numel(xt)-1)) where sprintfc is an undocumented function creating cell arrays filled with custom strings and xt is the XTick you have fetched from the current axis in order to know how many of them there are. Example with dummy data:...

image,matlab,user-interface,graph,plot

So figured it i had to write the handles of the GUI to the workspace in the opening function of the gui % --- Executes just before VR_gui is made visible. function VR_gui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure...

python-2.7,matplotlib,plot,interactive

For interactive graphics, you should look into Bokeh (http://bokeh.pydata.org/en/latest/docs/quickstart.html). You can create a slider that will bring up the time slices you want to see.

To find the jump in the data, you can search for the place where the derivative of the function is the largest: [~,ind] = max(diff(y)); One way to plot the function would be to set that point to NaN and plotting the function as usual: y(ind) = NaN; plot(x,y); This...

matlab,plot,colors,scatter-plot,color-space

As pointed out by horchler, the mistake was in my color conversion (RGB to XYZ to xyY) which I had done external to MATLAB. On correcting the error, the following code produced the desired result. cieplot(); hold on x=[0.42 0.38 0.388 0.352 0.344 0.281] y=[0.48 0.45 0.5 0.45 0.452 0.352];...

You could do it like this, by finding the top left corner and fixing it to it. par(mar=c(4,6,4,4)) plot(rnorm(100), ylab="") loc <- par("usr") text(loc[1], loc[4], "Label", pos = 2, xpd = T) Playing around with pos and adding adj could change the position a bit. ...

You need to add "noise" to the radius of the circle, roughly around r=1: th = linspace( 0, 2*pi, N ); %// N samples noise = rand( 1, N ) * .1; %// random noise in range [0..0.1] r = 1+noise; %// add noise to r=1 figure; plot( r.*cos(th), r.*sin(th)...

You have duplicated (Material, Types) cases, lines does not appear appropriated. Try this, using points. tms=range(df[,"Time"]) ylims=range(df[,c("Value1","Value2")]) plot(NA,type="n",xlim=tms,ylim=ylims,xlab="Time",ylab="Val") df=df[with(df,order(Material,Time)),] mats=unique(df$Material) sapply(1:length(mats),function(ma){points(df[df$Material==mats[ma],"Time"], df[df$Material==mats[ma],"Value1"], col=ma,pch=15 ) }) df=df[with(df,order(Type,Time)),] library(RColorBrewer) coly<-brewer.pal(8,"Accent")[8:1]...

You need to use pointPlacement option with number value. For example: http://jsfiddle.net/9phfzewj/34/ Play around with values, which in my case are -0.1 for lefts and 0.1 for rights. As long as series.grouping is enabled, pointPlacement refers to the previous series position....

Your code works for me, just fixed some } and ]. http://jsfiddle.net/3qo8kg2o/ But I think you should use polyline instead....

One approach is, to have all possible dates and values first as an PHP array: $labels = array( "May 1st" => 0, "May 2nd" => 0, "May 3rd" => 0, "May 4th" => 0, "May 6th" => 0, "May 6th" => 0, .... ); Then fill all the values from...

python,csv,matplotlib,graph,plot

you need to turn x and y into type np.array before you calculate above_threshold and below_threshold, and then it works. In your version, you don't get an array of bools, but just False and True. I added comma delimiters to your input csv file to make it work (I assume...

Your code is obfuscating to me what your final result is supposed to be exactly. Maybe this: library(ggplot2) DF <- merge(xy.pop, xx.pop, by = "Var1") ggplot(DF, aes(y = Var1, xmin = -Freq.x, xmax = Freq.y, x = 0)) + geom_errorbarh() + geom_vline(xintercept = 0, size = 1.5) + theme_minimal() +...

This is because scale() returns a matrix rather than a data.frame. Just convert it back to a data.frame mydata <- data.frame(scale(mydata)) ...

Here's the way I would solve it, using your code from above to create the g object. This was trickier than at first glance because of the multi-color membership at the group/connectedness/cluster level that you wanted to attain.: ## Find cluster membership: c <- clusters(g) d <- data.frame(membership=c$membership, color=V(g)$color, id=1:length(V(g)))...

Here's a version that works with log-scale and linear scale axes. The trick is to express line locations in npc coordinates rather than user coordinates, since the latter are of course not linear when axes are on log scales. line2user <- function(line, side) { lh <- par('cin')[2] * par('cex') *...

In order to use ax(n) you need to provide plotyy with the right output arguments. In your case, you could use the following: figure; %// Here BarPlot and RegPlot are not really needed so you could replace them with ~. [ax,BarPlot,RegPlot] = plotyy(Pert, Rfootvel(:,i+1), Pert, 0,'bar','plot'); hold(ax(1), 'on'); legend('Pert 1-8',...

The problem is, since each of your columns has a non-numeric value in the first non-header row, pandas automatically parses the entire column to be text. One workaround is to skip the text row like this: df=pd.read_csv(filepath, sep=",",skiprows=[1]) Then when you try to plot it will work just using: df['coal...

Without spelling out the code: Pick initial circle, e.g. Position [0,0] and radius 1. Initialise list for positions and radii. Pick random position and radius r. If circle is not in big one (I.e. sqrt(pos(1)^2+pos(2)^2) + r > 1) continue with 3. If overlap with other circles (distance between positions...

I came up with an approximate solution exploiting plot2 and the classification syntax y*x=i. IMHO (after an extensive process of RTFM and technical paper search), your original request of putting all the plots into one graph cannot be simply done since The by statement is designed for producing DISTINCT graphs....

matlab,graphics,plot,matlab-figure

Approach 1: using rectangle, solid colors. Some circles may be covered The simplest (although not very intuitive) way to plot circles is to use the rectangle function with the 'curvature' property set to [1 1]. To have the circles filled, specify the color via the 'facecolor' property. The color of...

I assume with "2d-line" you mean a 2d-plot. This is done by the plot-function, so there is no need of surf or mesh. Sorry, when I got you wrong. The following code does what I think you asked for: % Generate some propagating wave n = 20; t = linspace(0,10,100);...

Combining the example by @Robert and code from the answer featured here: How to get a reversed, log10 scale in ggplot2? library("scales") library(ggplot2) reverselog_trans <- function(base = exp(1)) { trans <- function(x) -log(x, base) inv <- function(x) base^(-x) trans_new(paste0("reverselog-", format(base)), trans, inv, log_breaks(base = base), domain = c(1e-100, Inf)) }...

I can reproduce the bug. The solution , add (push viewport) a viewport to the vieport tree to insert the grid plot. But it forget to remove it ( pop viewport). Adding the line at the ned will fix the problem : popViewport() Test the solution: To test this fix,...

From gnuplot docs, define styles as: set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 5 ps 1.5 # blue set style line 2 lc rgb '#dd181f' lt 1 lw 2 pt 7 ps 1.5 # red ... and plot: plot ... w lp ls 1 #...

Try this, library(gtable) library(grid) library(ggplot2) exprGrob <- function(..., parse=TRUE, spacing=unit(0.5,"line")){ labs <- list(...) if(parse) labs <- lapply(labs, function(x)parse(text=x)) labs <- lapply(labs, textGrob, gp=gpar(fontface="bold",fontfamily="Times")) widths <- do.call(unit.c, lapply(labs, grobWidth)) heights <- do.call(unit.c, lapply(labs, grobHeight)) g <- gtable_matrix(name = "expr", grobs = matrix(labs, ncol=1, nrow=length(labs)), widths = max(widths), heights = heights+spacing) g...

There are two problems here. The first problem is that you use as.POSIXlt that produces lists instead of as.POSIXct which produces vectors. Therefore melt cannot do its job properly. Try this instead: df$time <- as.POSIXct(paste(df$Date, df$Time)) The second problem is that you group on the same variable that is used...

One way to do it would be to use clip: data = read.csv("TEST.csv", header = FALSE) plot(data$V1,data$V2) fit <- lm(data$V2~data$V1) abline(fit, col=1) data1 = read.csv("TEST1.csv", header = FALSE) clip(min(data1$V1), max(data1$V1), min(data1$V2), max(data1$V2)) fit1 <- lm(data1$V2~data1$V1) abline(fit1, col=2) data2 = read.csv("TEST2.csv", header = FALSE) clip(min(data2$V1), max(data2$V1), min(data2$V2), max(data2$V2)) fit2 <- lm(data2$V2~data2$V1)...

You could use mtit to create an invisible axes around the subplots. mtit returns the handle to that axes, for which you can then create xlabel and ylabel. Example: % create sample data my_data = arrayfun(@(x)rand(10, 2) + repmat([x, 0], 10, 1), 1:6, 'UniformOutput', 0); figure; clf ah = gobjects(6,...

Using mtext is not so good but maybe! op=par( mfrow = c( 1, 2 ), oma = c( 1.3, 0, 0, 0 ) ) plot(rnorm(120), rnorm(120)) plot(rnorm(120), rnorm(120)) mtext("Legend that covers both plots", side=1, cex=1.5, col="red",outer = T, xpd=TRUE) mtext("Legend that covers both plots", line = -3,cex=1.5, col="red",outer = T)...

While you're creating your temperature data arrays, you need to parse the temperature value as a float. Make sure to parse the value as a float for both graphs. You're doing this for your humidity variable, and that is why the tooltip is working for that series. var temperature =...

csv,plot,gnuplot,function-fitting

You can use the solution offered in the comments with a system() call, or use stats: Option 1: N = floor(system("wc -l output.csv")/100.) Option 2: stats output.csv N = floor(STATS_records/100.) ...

You have given line2D (x1, y1), (x2, y2), but you need to give it (x1, x2), (y1, y2) line = matplotlib.lines.Line2D((-2.33,4.33),(10,-10.0)) ...

I think the code below will work. In short, I determine the densities of each vector, approx to some known vector of x values, jam it all together in a matrix, and then calculate the summary stats and plot. Is this what you were looking to do? #Make up some...

For the 90 degree rotations, this is an easy solution: image(t(flip(x, 1))) image(t(flip(x, 2))) plotRGB(t(flip(x, 1))) plotRGB(t(flip(x, 2))) For the 45 degree and 135 degree rotation, it will be a bit trickier. There are probably other ways, but I'll use the persp function and give different angles to the theta...

Try with yaxs="i" as well as xaxs: par(mar=c(0,0,0,0), xaxs = "i", yaxs="i") works for me......

One possibility would be to loop over the names of the list: lapply(names(comp.surv), function(x) plot(comp.surv[[x]], main = x)) Or slightly more verbose, loop over the list indices: lapply(seq_along(comp.surv), function(x) plot(comp.surv[[x]], main = names(comp.surv)[x])) ...

python,csv,matplotlib,plot,genfromtxt

I think if you set usemask =True in your genfromtxt command, it will do what you want. Probably don't want filling_values set either arr = np.genfromtxt('DemoData.csv', delimiter=',', dtype=None, missing_values='', usemask=True) you can then plot using something like this: for n in range (1,len(names)): plot(arr[1:,0][logical_not(arr[1:,n].mask)], arr[1:,n].compressed()) ...

matlab,plot,matlab-figure,iso,loglog

Answer Part I The common way to put text somewhere is the annotation function. It's quite hard do get it right with its basic functions, so rather use it with the latex interpreter as it allows you to specify the gap between every line with '\vspace{gapwidth}' and a lot more...

The problem is that you create two legends. You get nicer results with only one. For that you need to store the line artists: l1, = plot.plot(time, pressure, label=r'\textit{Raw}') # ... l2, = ax2.plot(time, needle_lift, label=r'\textit{Needle lift}', color='#4DAF4A') And then you can use them to create the legend, by supplying...

grDevices::n2mfrow() can do it for you

You can set clip_on=False in a Rectangle patch so that it can extend beyond the axis boundaries. import matplotlib.pyplot as plt import matplotlib.patches as mpatches import numpy as np fig,ax=plt.subplots(2,1) x=np.linspace(0,np.pi*2,50) ax[0].plot(x,np.sin(x),'b-') ax[1].plot(x,np.sin(x),'b-') rect=mpatches.Rectangle([0.35,0.1], 0.1, 0.8, ec='k', fc='g', alpha=0.5, clip_on=False, transform=fig.transFigure) ax[1].add_patch(rect) fig.savefig('figure.png') Note: setting the rectangle on the first...

Here is a very simple example of a way you could use datacursormode, an interactive cursor which enables you to select points on your figure and get their coordinates. You could easily customize the example and store the coordinates in variables and so on, but I'll let this part up...

r,graph,plot,ggplot2,time-series

Two ways of doing this: If sample data created as follows: Full.df <- data.frame(Date = as.Date("2006-01-01") + as.difftime(0:364, units = "days")) Full.df$Month <- as.Date(format(Full.df$Date, "%Y-%m-01")) Full.df[paste0("Count.", c("S", "G", "W", "F"))] <- matrix(sample(100, 365 * 4, replace = TRUE), ncol = 4) Optimal way using reshape2 package: molten <- melt(Full.df, id.vars...

You don't need to create the xts objects persistently. Note the modification of the use of your names() function in the for() specification as well: for (i in names(log_return)[2:11]){ plot(na.omit(xts(log_return[[i]],log_return$Date)), xlab = "Date", ylab = "log_return", main = i) } Or, as @SpacedMan mentions, you can use get() to reference...

This should work gaps = data.frame(gap.pos = c(50646312, 50647076, 50647511, 50647512, 50647513, 50647546)) gap_plot <- ggplot(gaps) + geom_point(aes(x=gap.pos, y=1)) you have to call the plot you produced to actually see the plot gap_plot ...