plot,gnuplot,histogram , Distinct bars of different group in Gnuplot for printing

Distinct bars of different group in Gnuplot for printing


Tag: plot,gnuplot,histogram

The problem for me is how plot (using gnuplot) bars with different styles in a figure so that they can be print.

Take data from for example, the data is:

hdisk2 420 425 410
hdisk3 700 780 760
hdisk4 450 450 452
hdisk5 680 702 690
hdisk6 320 330 329
hdisk7 530 515 514


set terminal png truecolor
set output "diskimage.png"
set style data histograms
set style fill solid 1.00 border -1
plot "disk.txt"  using 2:xtic(1) title "Oct-09 data growth(gb)", '' using 3 title "N
ov-09 data growth(gb)", '' using 4 title "Dec-09 data growth(gb)"

The gnuplot script works and bars are labelled with different colours for distinction of three groups. However, once it is print on the paper, the colours are lost and it is hard to distinct bars anymore.

My question is whether the bars can be plot with different style for different groups. E.g., Fill bars for different group with different filled style? enter image description here


Use fillstyle pattern to select between different fill patterns for each bar type, and lt -1 (or lc rgb 'black') to use black as line color:

set terminal pngcairo
set output "diskimage.png"
set style data histograms

plot 'Disk.txt' using 2:xtic(1) fs pattern 2 lt -1 title "Oct-09 data growth(gb)",\
     '' using 3 fs pattern 1 lt -1 title "Nov-09 data growth(gb)",\
     '' using 4 fs pattern 4 lt -1 title "Dec-09 data growth(gb)"

enter image description here

See the output of the test command (Gnuplot line types) to check the available fill patterns for the desired output terminal.


How to switch Matlab plot tick labels to scientific form?

I have a semilogarithmic plot which works so far with semilogx. Now I would like to change the tick labels. Now it says 10^8 10^9 ... 10^13, but I would like to see 1e8, 1e9, ... 1e13 on the x-axis. How can I change that? Cheers Manuel...

How to set x-axis with decreasing power values in equal sizes

Currently I am doing some cumulative distribution plot using R and I tried to set x-axis with decreasing power values (such as 10000,1000,100,10,1) in equal sizes but I failed: n<-ceiling(max(test)) qplot(1:n, ecdf(test)(1:n), geom="point",xlab="check-ins", ylab="Pr(X>=x)")+ geom_step() +scale_x_reverse(breaks=c(10000,1000,100,10,1)) +scale_shape_manual(values=c(15,19)) It seems that the output has large interval for 10000, then all the...

how can i plot a route map?

I am writing a simple application to plot multiple marker in the google map and connect it thought a path as it looks like a route . I can plot multiple marker . and search some article which plot the route map . but i can not plot it ....

matlab plots as movie with legend

i have a question regarding legend for movies. This is my code: fig = figure(); for i = 1: 70000 plot(signal1) hold on; plot([i,i],[-5,5]) plot(signal2,'r') hold off; title('\fontsize{14} my data'); legend('signal1','signal2'); axis tight; f(i) = getframe(fig); end The legend shows the same colors for the first two things I plot....

R Shiny - set reactive width of a plot output

I am filtering a tbale and a heat-map simultaneously. During filtering, the width of the table is changing such that width of particular columns remains the same. Width of the heat-map remains the same during filtering. I want the heat-map to change its weight in the same way as the...

Add a gap between the second and third series in a Highcharts column plot with four series displayed

I have a Highcharts column plot that shows four series. I would like series one and two to be touching each another (the two blue ones), then have a small gap, and then have series three and four touching each another (the orange ones). Can this be done? I haven't...

Plot SpatialPoints “ylim” behaviour incomprehensible

I'm trying to plot a SpatialPoints object using the generic function from the Package graphics. The extent of the plot should be exactly the size of the outermost datapoints. Here's a simple example where the ratio of delta x over delta y (outermost values) is 1: library(sp) xydata <- as.matrix(cbind(c(1,1,2,2,1.5),c(1,2,2,1,1.5)))...

Matplotlib: How to force integer tick labels?

My python script uses matplotlib to plot a 2D "heat map" of an x, y, z dataset. My x- and y-values represent amino acid residues in a protein and can therefore only be integers. When I zoom into the plot, it looks like this: As I said, float values on...

“Icon” (ISOTYPE) charts in R shiny with Javascript

I'm working on a project to build several models for data analysis and reporting using R and the amazing Shiny framework for web development. I'm getting started with R and Shiny but I've had an amazing experience so far, yet, I'd like to get some help in case someone has...

Matplotlib: Plot the result of an SQL query

from sqlalchemy import create_engine import _mssql from matplotlib import pyplot as plt engine = create_engine('mssql+pymssql://**:****@') connection = engine.connect() result = connection.execute('SELECT Campaign_id, SUM(Count) AS Total_Count FROM Impressions GROUP BY Campaign_id') for row in result: print row connection.close() The above code generates an array: (54ca686d0189607081dbda85', 4174469) (551c21150189601fb08b6b64', 182) (552391ee0189601fb08b6b73', 237304) (5469f3ec0189606b1b25bcc0',...

Shift Plot Data Along X Axis Matlab

I cannot get Matlab to plot a a second time series to specific points along the x axis. My data are two time series. Time series A is a 5 X 1 and time series B is a 7 X 1. I need A to plot on xticklabels 1-5. Then,...

matplotlib mean interval plot

I'm transitioning from R to python, and was looking to plot the mean line of a two variables. It is the plot of the x variable is split into intervals for the x axis, and mean of the y variable for the y axis. For example, if I have 1000...

Animate through multiple 2D Matlab plots

I have multiple 2D line plots in Matlab (they represent some wave moving through space). Each plot represents the wave at some time t. I want to animate through these plots (i.e. show the first plot for a fraction of a second, then show the next one, and the next,...

Set categorical axis labels with scales “free” ggplot2

I am trying to set the labels on a categorical axis within a faceted plot using the ggplot2 package (1.0.1) in R (3.1.1) with scales="free". If I plot without manually setting the axis tick labels they appear correctly (first plot), but when I try to set the labels (second plot)...

Object-oriented access to fill_between shaded region in matplotlib

I'm trying to get access to the shaded region of a matplotlib plot, so that I can remove it without doing plt.cla() [since cla() clears the whole axis including axis label too] If I were plotting I line, I could do: import matplotlib.pyplot as plt ax = plt.gca() ax.plot(x,y) ax.set_xlabel('My...

MATLAB - How to merge figure sections vertically

I want to display three figures in a figure window. Assuming that I divide 2x2 regions. subplot(2,2,1) ---------+----------- | R1 | R2 | ---------+----------- | R3 | R4 | ---------+----------- I want to show a figure merging R1 and R3 ant other two in R2 and R4 I can display...

gnuplot highlighting points when with lines

I have 4 points I would like to plot using gnuplot, but with lines. The problem is, I can't find how to highlight these 4 points on the drawn line. I would like for the plot to be a line through the points, but that these points are also clearly...

How to put several formulas outside of a plot (top) using ggplot2?

I have problems using annotation_custom. Here is the dataset: DOSE PROD pH 1 0 CL 4.3550 2 0 CO 4.3250 3 0 CZ 4.1475 4 0 PF 4.2300 5 0 RP 4.1225 6 25 CL 4.3420 7 25 CO 4.3520 8 25 CZ 4.7840 9 25 PF 4.2640 10 25...

Read CSV and plot colored line graph

I am trying to plot a graph with colored markers before and after threshold value. If I am using for loop for reading the parsing the input file with time H:M I can plot and color only two points. But for all the points I cannot plot. Input akdj 12:00...

rCharts doesn't render the plot in shiny app

I am using following simple shiny app code snippet to plot the output in the main pannel. But it doesn't render the plot as expected. It shows nothing in the browser. But When i run only the mPlot portion, it displays the plot in RStudio correctly with all interactions. ui.R...

Align axis ticks with bins in a lattice histogram

I plotted a histogram using Lattice histogram(~Time |factor(Bila), data=flexi2, xlim= c(5, 15), ylim=c(0, 57), scales=list(x=list(at=seq(5,15,1))), xlab="Time", subset=(Bila%in% c(""))) The bins I get do not match the exact hours, whereas I would like the bin to start at the exact hour, for example, 6,7 etc. I use lattice since I want...

Plotting two different arrays of different lengths

I have two arrays. One is the raw signal of length (1000, ) and the other one is the smooth signal of length (100,). I want to visually represent how the smooth signal represents the raw signal. Since these arrays are of different length, I am not able to plot...

Python: matplotlib - probability mass function as histogram

I want to draw a histogram and a line plot at the same graph. However, to do that I need to have my histogram as a probability mass function, so I want to have on the y-axis a probability values. However, I don't know how to do that, because using...

Is it possible to “print” gnuplot's output directly to STDOUT?

I am using a third-parter utility named gnuplot-iostream to invoke gnuplot from C++ in the back-end of a web application. That web application is executed under CGI, so anything that goes to STDOUT is the result to browser. In this case, the web request will be for the image itself,...

gnuplot rowstacked histogram: how to put sum above bars

This question is related to gnuplot histogram: How to put values on top of bars. I have a datafile file.dat: x y1 y2 1 2 3 2 3 4 3 4 5 and the gnuplot: set style data histogram; set style histogram rowstacked; plot newhistogram 'foo', 'file.dat' u 2:xtic(1) t...

Read One Input File and plot multiple

I am trying to read one input file of below format. Where Col[1] is x axis and Col[2] is y axis and col[3] is some name. I need to plot multiple line graphs for separate names of col[3]. Eg: Name sd with x,y values will have one line graph and...

Putting space between bars using bar function

I am try to plot 16 bars, 8 of these belong to one group. I want to give this group the red color, the other 8 belong to another group which is given the blue color. I would like to arrange the bar in pairs, each pair containing one from...

gnuplot - get errors on fit parameters, get fit output values as variables, print variable to screen

Initial Question (Partially Answered) I am using gnuplot's fitting routines to fit a function to some data, and extract a "characteristic decay time constant". (I call this parameter d in my fitting function.) I have used the script code set fit quiet to prevent reams of text being printed to...

Plotting random signal on circle

I have some random signal (for example sin signal) with the time scale. t=0:0.1:2*pi y=sin(t) plot(t,y) Now I want to draw this signal on this circle. So the time vector actually becomes an envelope of the circle. Envelope of the circle represents "y = 0" in cartesian coordinate system. Here...

Add a segment of a regression line to a plot

I have 4 regression lines and I want to have them in one plot. Here is my simple code: 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) fit1 <- lm(data1$V2~data1$V1) abline(fit1, col=2) data2 = read.csv("TEST2.csv", header = FALSE) fit2 <-...

SAS Gplot overlay line plots

I am trying to plot two sets of line graphs on the same chart: /* make data */ data test ; do i = 1 to 2 ; do x = 1 to 5 ; y = i*x ; z = 0.5*i*x ; output; end ; end ; run ;...

Matlab - plot bar and line graph on the same y axis

I'm trying to plot a line graph and a bar graph on the same y-axis: figure; plotyy(Pert, Rfootvel(:,i+1), Pert, 0,'bar','plot'); hold(ax(1), 'on'); legend('Pert 1-8', 'Base'); ylim(ax(2), [0 1]); title(['The avg pert velocity of the first step vs the avg base velocity, PP' num2str(j)]); Unfortunately, setting the second y-axis limit like...

Align bars in ciplot

I'm working with the ciplot graphing module for Stata and am encountering a problem with the alignment of bars when I use the by() option. Here's a trivial example demonstrating the issue: webuse citytemp, clear ciplot heatdd cooldd, by(region) horizontal recast(conn) So, the graph shows means and confidence intervals for...

How to plot columns numbered greater than 1000 in gnuplot

I have a file with 1600 columns. plot "file" using 1:999 title columnhead(999) plots column 999, but plot "file" using 1:1000 title columnhead(1000) produces column 100 instead of 1000, producing the same result as plot "file" using 1:100 title columnhead(100) Apparently large column numbers are wrapped. Is there a work-around...

Can I set a default Y range in gnuplot?

My graphs will be generated based on runtime data, such as user-provided time ranges. I can't know ahead of time whether data within the requested xrange will actually exist. In the case that it's not, I'd like to show a blank plot (with X=time range as requested, but arbitrary Y...

How to add shading through all subplot

I have a question about add shading in my figure. I need to shading all subplot like the picture below, how to do it in Python?

Gnuplot plotting all datafiles automatically

I have multiple *.data files each has same format and can be plotted with this simple script: cat << __EOF | gnuplot -persist set terminal pdf set output 'out.pdf' set datafile separator ";" set boxwidth 0.5 set style fill solid plot "xxx.dat" using 1:3:xtic(2) with boxes __EOF How can i...

Flot Graph inconstencies with axis and tooltips?

I am working on an application where I am trying to plot a similar graph to what is plotted at Open Weather. I am using the FlotJS library to query their API and plot the graphs. Here is my code. I apologize for the verbosity. /* * RUN PAGE GRAPHS...

Python: Using panda to import csv. Trying to plot a column but gives me an error saying “no numerical data to plot”

I'm trying to read following csv-file with panda and plot a column of it: data type,approved mining area,mined area,coal content,earth rate,coal rate,waste ratio unit,ha,ha,Mt,Mm3/a,Mt/a, Garzweiler,11400,3096,1246,140,37.5,4.4 Hambach,8500,4224,1500,275,40,5.2 Inden,4500,1655,358,87.5,22.5,3.6 which gives me the following (only a part so it fits here): data type approved mining area mined area coal content earth rate...

making a choropleth from SpatialPolygonsDataFrame- ggplot vs ggplot2 vs plot?

I have a shapefile, specifically, a SpatialPolygonsDataFrame, called cdtract. that contains one variable for each district called varcount. varcount is either "NA" or 1. When I do plot(cdtract) ...I see the map printed out but I don't see the tracts that are '1' in varcount marked any differently from those...

Gnuplot bar chart from this CSV input

I have csv file data.dat for example with these values: #W=1 0;sqlite;11500 1;hsql;14550 2;h2;17550 #W=2 0;sqlite;11000 1;hsql;13800 2;h2;16500 #W=3 0;sqlite;11000 1;hsql;13800 2;h2;16500 #W=4 0;sqlite;11000 1;hsql;13800 2;h2;16500 I need to plot bar charts into pdf. each data for each graph starts with title #W1,#W2.... i have tried this script: cat <<...

Matplotlib heatmap: Image rotated when heatmap plot over it

I am trying to plot a heatmap on top of an image. What I did: import matplotlib.pyplot as plt import numpy as np import numpy.random import urllib #downloading an example image urllib.urlretrieve("", "/tmp/cards.png") #reading and plotting the image im = plt.imread('/tmp/cards.png') implot = plt.imshow(im) #generating random data for the histogram...

Set label on group multiplot in gnuplot

Im plotting one picture with 4 different graphs using gnuplot. Labels for their x and y axes have the same meaning. If Im plotting it like this: set multiplot layout 2,2 rowsfirst set xlabel "x" set ylabel "y" set title offset -3,-3 set xrange [20:70] set yrange [0:15000] set title...

How to concatenate 3 histograms on the same graph in Matlab

I have calculated 3 histograms for an rgb image using imhist function in Matlab, one for each channel. I want to plot these histograms on the same graph, where for instance, the histogram for the first (red) channel stretches on the x axis from 0 to 255, the histogram for...

Can I plot times when they're given as UNIX timestamps with added milliseconds?

I'm using gnuplot 4.4 on CentOS 6.6. I've found many examples online showing that the following (note the use of %.3S) will enable timestamps like "12:42:51.047" to be parsed and used as X axis values: set xdata time set format x "%H:%M:%.3S" set timefmt "%H:%M:%S" However, my input is not...

Customized back-to-back histogram in R

Given this example of back to back histogram: set.seed (123) xvar <- round (rnorm (100, 54, 10), 0) xyvar <- round (rnorm (100, 54, 10), 0) myd <- data.frame (xvar, xyvar) valut <- as.numeric (cut(c(myd$xvar,myd$xyvar), 12)) myd$xwt <- valut[1:100] myd$xywt <- valut[101:200] xy.pop <- data.frame (table (myd$xywt)) xx.pop <- data.frame...

How to rotate an image R raster

I have code below which saves an image to my pc. I would like to rotate that image by 45,90 and 135 degrees around its center (or bottom left hand corner) and then save as 3 different images. How could I do that? library(raster) r1 <- brick(system.file("external/rlogo.grd", package="raster")) x <-...