I created a few charts on D3.js and they are running well at Chrome. However I'm having the follow error on Firefox.
Error: path.isPointInFill is not a function
I have looked at the documentation,
https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/isPointInFill, and it's not supported on Firefox, but I didn't found an equivalent or a substitute.
What I need to do:
I have a chart XY, which is separated into several paths (with different shapes). I'm plotting the results from an user in X and Y and I need that the path where the users is located change the color.
Follow example..
...after that I plotted the user I need change the color of the p6.
Related
I generated a table with iText7 (C#):
var cell = new Cell().Add(new Paragraph(headers[c]).SetFont(font).SetFontColor(ColorConstants.WHITE).SetFontSize(size).SetBold());
cell.SetBackgroundColor(color);
cell.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
cell.SetPadding(0);
cell.SetBorder(new SolidBorder(1));
table.AddCell(cell);
Document has the table, but on certain scalings, it looks weird on the edges:
Taking a closer look on the image above:
If however I change the zoom in the viewer directly, it looks OK:
How do I get rid of these unnecessary parts from the border?
I'm attaching here the resulted PDF for reference:
Download sample PDF
I also noticed that on iText KB pages, there is this kind of behavior:
https://kb.itextpdf.com/home/it7kb/faq/how-do-i-change-the-border-color-of-a-pdfpcell
See the red and blue bars' left edges:
This behaviour is not uncommon in PDF or other print drivers where vectors are printed rather than plotter definitions (often called "Dangles". It would be worse if the definition was rounded or square, rather than butt, and join as "mitre" cannot apply, see below). The overlap is intentional (to ensure both lines are inclusive). In a laser drum print that may be desirable overkill, but disastrous for any inkjet or screen. It looks like the cell is not bordered by a box, but using common straight vectors. Again this is often desirable optimisation but not when the weight is not honoured. Thus it depends if the viewer is using the correct thickness.
All desktop PDF viewers (icluding Chrome and FireFox) I tested showed the lines correctly as clean overlap without "Dangles". Acrobat has a reputation for undesirably thickening or thinning its standard defined lines depending on its user settings.
I have a problem with the preview window of plots from RNotebook.
I am running GAM-models for different tree species and store them in a nested dataframe. When I afterwards run some model diagnostics or plotting function in RNotebook an odd behaviour occurs.
So lets say I want to plot the smooths for each tree species gam model with customized function
# plotting the effects of the model with gratia
gam_plot_gratia_all(gam_base, group_var = group_var)
here my custom-function:
gam_plot_gratia_all = function(gam_input, group_var) {
map2(gam_input$fit_gam, gam_input[[group_var]], ~ show(gratia::draw(.x)))
}
gam_base is a nested dataframe which contains the gam-models in the fit_gam column. The function works and I get three plots:
When I open the plots in the preview window, the last plot (the very right one) is shown properly and after enlarging the preview window, adjusts the single ggplots to the proper size:
However, when selecting one of the previous plots, the single smooth-plots do not adjust to the larger window size, but remain in the default size:
Of course I can create multiple plots and split them on different pages, but for a quick preview, this is quite a nice feature or RNotebook. The example with the gratia-plots is just for demonstration. The behaviour remains the same when I plot other ggplots or use other plotting packages, so maybe there are some options in RNotebook, where I can tackle this problem?
I also tried "print" in my function calls, and also wrapped the print function around my map2-call. I use the latest version of RStudio (2022.07.2 Build 576) and Windows.
I found that apparently, a mapped version of imshow function does not work in subplot. Is this by design?
The following script
rgb=imread('../FruitSample_small.png');
[ind,map]=rgb2ind(rgb,4);
figure
imshow(ind,map)
figure
subplot(5,1,1);
imshow(ind,map)
subplot(5,1,2);
imshow(ind==0)
subplot(5,1,3);
imshow(ind==1)
subplot(5,1,4);
imshow(ind==2)
subplot(5,1,5);
imshow(ind==3)
produces the following result
i.e. mapped version looks black. If I plot mapped version only (5 times) it looks ok. I.e. subsequent plotting apparently change the palette.
How to plot all these 5 images on same figure then?
Colormap is a property of the figure, not the axis. The second call to imshow resets the Colormap for the entire figure. Here is some more information and a Matlab file exchange solution to the problem. If you download the function described in that link, freezeColors, you can use it in your code like this.
rgb=imread('peppers.png'); % example image included in matlab
[ind,map]=rgb2ind(rgb,4);
figure
imshow(ind,map)
figure
subplot(5,1,1);
imshow(ind,map)
freezeColors % keep colors the same after other subplots are displayed
subplot(5,1,2);
imshow(ind==0)
freezeColors
subplot(5,1,3);
imshow(ind==1)
subplot(5,1,4);
imshow(ind==2)
subplot(5,1,5);
imshow(ind==3)
And the resulting second figure will look like this:
I have 3 series on my chart. Is it possible to give user only one serie to modify (as dragable line) whilst other can't be modify?
This is totally undocumented, but browsing the source for the dragable plugin it is as simple as setting the isDragable property for that series to false.
series:[{},{isDragable:false}] //set the second series to be undraggable.
See working example here.
I need to plot and display several jpeg images in a single combined display (or canvas?). For example, suppose I have images {a,b,c,d}.jpg, each of different size, and I would like to plot them on one page in a 2x2 grid. It would be also nice to be able to set a title for each subplot.
I've been thoroughly looking for a solution, but couldn't find out how to do it, so any ideas would really help. I would preferably use a solution that is based on the EBImage package.
There are two ways how to arrange several plots with base graph functions, namely par(mfrow=c(rows,columns)) (substitute rows and columns with integers) and layout(mat) where mat is a matrix like matrix(c(1,2,3,4)).
For further info see ?par, ?layout, and especially Quick-R: Combining Plots.
However, as your question is about images I don't know if it helps you at all. If not, I am sorry for misinterpreting your question.
To add to Henriks solution, a rather convenient way of using the par() function is:
jpeg(filename="somefile.jpg")
op <- par(mfrow=c(2,2)
#plot the plots you want
par(op)
dev.off()
This way, you put the parameters back to the old state after you ran the code. Be aware of the fact this is NOT true if one of the plots gave an error.
Be aware of the fact that R always put the plots in the same order. Using mfrow fills the grid row by row. If you use mfcol instead of mfrow in the code, you fill up column by column.
Layout is a whole different story. Here you can define in which order the plots have to be placed. So layout(matrix(1:4,nrow=2) does the same as par(mfcol=c(2,2)). But layout(matrix(c(1,4,3,2),ncol=2)) places the first plot lefttop, the next one rightbottom, the third one righttop, and the last one leftbottom.
Every plot is completely independent, so the titles you specify using the option main are printed as well. If you want to have more flexibility, you should take a look at lattice plots.
If you do not want the images in a regular grid (the different sizes could imply this), then you might consider using the subplot function from the TeachingDemos package. The last example in the help page shows using an image as a plotting character, just modify to use your different images and sizes/locations.
The ms.image function (same package) used with my.symbols is another possibility.