Using the package implicit plots how do I color the region under the line 2*x-y=4 and 2*x+y=4.
with(plots, implicitplot):
implicitplot([x=5/2,2*x-y=4,2*x+y=4,3/2*x-2*y=7/4],x=1.5..2.6,y=0..1.5);
with(plots, implicitplot):
plots:-display(
implicitplot([2*x-y>4,2*x+y<4],
x=1.5..2.6,y=0..1.5,filledregions),
implicitplot([x=5/2,2*x-y=4,2*x+y=4,3/2*x-2*y=7/4],
x=1.5..2.6,y=0..1.5)
);
Related
With gnuplot 5.4 (Win7), I tried to animate circles in 3D, basically the animated version of this.
The test data $Data contains random x,y,z coordinates, random sizes and random colors from 0x0000000 to 0xffffff. When the animated GIF is created, the circles are changing the color depending on the viewing angle.
As far as I know, GIF is limited to 256 colors, so it is clear that not all colors from 0x0000000 to 0xffffff can be displayed.
I expected gnuplot to take somehow the nearest color and stick with it.
However, I didn't expect at all that the color of the circles would change depending on the angle.
Why is this? How to work around this?
Code:
### animated plot with circles in 3D (only for gnuplot >=5.4)
reset session
set term gif size 400,400 animate delay 30 optimize
set output "WithCircles3D.gif"
# create some test data
set print $Data
do for [i=1:100] {
print sprintf("%g %g %g %g %g", rand(0), rand(0), rand(0), rand(0)*0.02+0.02, int(rand(0)*0xffffff))
}
set print
set view equal xyz
set xyplane at 0
set border 4095
set xtics 0.2
set ytics 0.2
set ztics 0.2
set style fill solid 1.0
do for [a=5:360:10] {
set view 60,a,1.25
splot $Data u 1:2:3:4:5 w circles lc rgb var notitle
}
set output
### end of code
Result:
Result 2: (different random set when exporting single PNG frames with term pngcairo and put them together as animated GIF with some other software.)
I think the work-around is to not use the "optimize" option. It relies on upstream support (in libgd) that has been unreliable if not outright broken for years now. Probably we should deprecate the gnuplot option or remove it altogether.
The example you show works correctly if you remove that keyword, right?
I am using Bar Chart of fl_chart plugin. I want to give gradient color to bar graph. Below is the line where I want give color.
BarChartRodData(y: 12, color: Color(0xFF639ed1),width: 12)
But it is not possible to set gradient color to the ##color## property unless it is colors.
Is there any way to set gradient color to color property?? Please help me..
If you pass just one color, the solid color will be used, or if you pass more than one color, we use gradient mode to draw. then the gradientFrom, gradientTo and gradientColorStops
For an example ,
final List<Color> color = <Color>[];
color.add(Colors.blue[50]);
color.add(Colors.blue[100]);
color.add(Colors.blue);
final List<double> stops = <double>[];
stops.add(0.0);
stops.add(0.5);
stops.add(1.0);
Please refer https://pub.dev/documentation/fl_chart/latest/fl_chart/BarChartRodData-class.html for BarChartRodData class variables
I am trying to use the layered methods to overlay few spatstat spatial objects. All these objects are for the same window. I have an im layer (density) from a ppp. I want to make this layer a bit transparent in order to have a better visibility of the other objects in the layered object.
How can I control the transparency of this density plot (im)? Is there something like alpha or transparency parameter for the plot.im ?
UPDATE:
library(spatstat)
pipes=simplenet
plot(pipes)
point_net = as.ppp(runifpoint(10, win = Window(pipes)))
point_surface = density(point_net)
plot(point_surface)
layers= layered(point_surface, point_net, pipes)
plot(layers)
Here , I have plotted 3 layers. As you can see the density plot has very dark blues and reds. Yes, I can plot lines and points with different colours to make them visible, but it would nice to do simple stacked line, point plots and add a little bit of transparency to the density (im) plots.
The purpose is just to avoid complex customized plot colours and to explain to colleagues.
thank you.
First the commands from the original post:
library(spatstat)
pipes=simplenet
point_net = as.ppp(runifpoint(10, win = Window(pipes)))
point_surface = density(point_net)
layers= layered(point_surface, point_net, pipes)
plot(layers)
You need to provide a different colourmap to plot.im. There are two
ways you can do this:
Plot each layer individually using add = TRUE for subsequent
layers and provide the colour map when you plot the im object.
Pass a list of plot arguments when you plot the layered object you
have created above.
I find the first option easier for illustration, so I will do that
first. The default colourmap of spatstat is the 29th Kovesi colour
sequence (?Kovesi for more details on these sequences):
def_col <- Kovesi$values[[29]]
head(def_col)
#> [1] "#000C7D" "#000D7E" "#000D80" "#000E81" "#000E83" "#000E85"
To add transparency you can use to.transparent with your choice of
fraction for more/less transparency:
def_col_trans <- to.transparent(def_col, fraction = 0.7)
head(def_col_trans)
#> [1] "#000C7DB3" "#000D7EB3" "#000D80B3" "#000E81B3" "#000E83B3" "#000E85B3"
Now you just need to use this as your colourmap:
plot(point_surface, col = def_col_trans)
plot(point_net, add = TRUE)
plot(pipes, add = TRUE)
To do it with the layered object you have to make a list of plot
argument lists (containing NULL if you don't have additional
arguments):
layer_args <- list(list(col = def_col_trans),
list(NULL),
list(NULL))
plot(layers, plotargs = layer_args)
Assume we have a 5x4x3 3D grid, where each cell has a value:
0.5523 0.0495 0.1465 0.5386
0.6299 0.4896 0.1891 0.6952
0.0320 0.1925 0.0427 0.4991
0.6147 0.1231 0.6352 0.5358
0.3624 0.2055 0.2819 0.4452
0.1239 0.2085 0.9479 0.6210
0.4904 0.5650 0.0821 0.5737
0.8530 0.6403 0.1057 0.0521
0.8739 0.4170 0.1420 0.9312
0.2703 0.2060 0.1665 0.7287
0.7378 0.8589 0.1339 0.3329
0.0634 0.7856 0.0309 0.4671
0.8604 0.5134 0.9391 0.6482
0.9344 0.1776 0.3013 0.0252
0.9844 0.3986 0.2955 0.8422
How can I achieve a plot in gnuplot that is similar to this plot achieved in matlab using patch? Note that the grid cells has an alpha value of 0.8.
I have x-label range like this: 2.0237*e^10 to 15.055*e^10.
Now when I draw the graph then X-label values overlap.
How can I manage this without changing font size?
use "set xtics" to define a larger distance between the xlabel major tics.
You can also use "set format x " to define a more suitable format for the x-axes:
For example:
This draws the xlabel tics only at 2*e^10, 4*e^10, 6*e^10...
set xtics 2E10
This will display the label tics in a more compact form:
set format x "%1.0E"
You might also find this very helpful:
http://heim.ifi.uio.no/inf3330/scripting/doc/gnuplot/Kawano/tics-e.html#3.1