-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cropping from pgfplots is not always working for final SVG output #1023
Comments
I have ran across this issue with this when testing out my PGplot macro (which uses pgfplots). If I have points outside the range of the axes, those points affect the final size of the image, but are not included in the image causing the blank space as you described. Though when testing out your problem, I notice the issue only on my 2.18 server, but not on my development server (which the image is generated correctly). Do you notice this same behavior, that this only occurs on 2.18? The two servers have identical versions of texlive and dvisvgm, so unsure why one server has extra space and one server doesn't. I also think I only ever saw the issue when testing my PGplot macro when using it for problems on my 2.18 server and not when testing it with develop. |
That is interesting because it may help us track down where this is coming from. But for me on my develop server, I still have this issue. Out of curiosity, when you see this happen, has it always been excess space either below or to the left (not above or to the right?) |
I don't recall exactly where the excess area was, I was more focused on getting a working problem so I had my code limit the domain/codomain to match the axes view to avoid the issue. But I did some more testing, and it does appear the image will always appear in the top right (so bottom left is where the blank area is). Here is an example that might be easier to play with, you can just move points inside and outside the axes range.
For instance if I make points appear off grid in the upper/right, the image is generated correctly. I figured out why it was working on my develop server, I was still using the default |
I dug into the code a bit, and forced the .tex file to stick around. Here is the actual tex file that is being used to generate the output:
The main difference I noticed was the line |
When I try locally to I found this: But given that I am just getting blank DVIs from local |
@Alex-Jordan I didn't actually look at the |
The line There does seem to be a bug though as @Alex-Jordan's link shows. That was filed as an issue at pgf-tikz/pgf#1275, and a pull request that fixes it was merged. So in future releases of |
If you want to fix this on your system, then change line 130 of |
By the way, you will always see a blank dvi when using the |
That edit worked on my local system, and now I get an SVG that has proper bounding where I previously did not. Are you saying the the latest |
I don't think the fix is in Would it be worth adding a comment about this around the configuration to use |
Yes, the fix is actually not in The fix has been committed to the master branch of https://github.com/pgf-tikz/pgf (which is probably their develop branch). |
We could do something similar to what we do for the imagemagick policy file, and that we used to do for the issue with UTF-8 encoding with XMLRPC::Lite. Make a patch that is applied in the docker build, and also add instructions to the webwork 2.19 installation manual as to how to apply that patch. |
This patch is applied in the docker build. It can be applied on your server with the command `sudo patch -p1 -d / < /opt/webwork/webwork2/docker-config/pgfsys-dvisvmg-bbox-fix.patch.patch` Note this patch is specific to Ubuntu 22.04, so don't try it on other versions of Ubuntu or other linux distributions. This was the change made in pgf-tikz/pgf#1276 that was merged into the master branch of the to the pgf-tikz latex package on October 23, 2023 that fixes the issue reported in pgf-tikz/pgf#1275.
This patch is applied in the docker build. It can be applied on your server with the command `sudo patch -p1 -d / < /opt/webwork/webwork2/docker-config/pgfsys-dvisvmg-bbox-fix.patch.patch` Note this patch is specific to Ubuntu 22.04, so don't try it on other versions of Ubuntu or other linux distributions. This was the change made in pgf-tikz/pgf#1276 that was merged into the master branch of the to the pgf-tikz latex package on October 23, 2023 that fixes the issue reported in pgf-tikz/pgf#1275.
Add a patch for the dvisvgm issue observed in openwebwork/pg#1023.
There may be an issue with the
dvisvgm
flow for creating an svg fromPGlateximage.pl
. My server is usingdvisvgm
version 3.0.3, which is what came with TeXLive 2023. If I run the following problem, the SVG of the image has lots of excess space under the actual image. (The SVG source haswidth='217.624508pt' height='1907.534988pt'
, so clearly that height is way off.)I have built the PDF and PNG from the same source, and there is no issue like this. So it's either the DVI itself or the conversion from DVI to SVG where this excess space is introduced.
The excess space doesn't come out of nowhere either. It's because the domain for the plot starts at 0.01, where the function's output is -100. The excess space down there seems to be about right if you wanted to include (0.01,-100) in the plot. Even though that should be cropped out. You can play with where the plot domain starts, making it further from 0, and eventually the excess space goes away once the start of the plot actually begins at y=-8.
Weird thing: you do not get this behavior if you turn it all upside down. That is, change the
ymax
to positive 8, and change the function to 1/x, and you will not see this behavior with excess space above the graph. @drgrice1 showed something similar today but there was excess space to the left of the graph. It suggests that maybe part of what's going on has to do with some plotted node with negative coordinates not being properly accounted for when it's time to crop stuff out of the DVI.Note: independent of PG/WeBWorK, I tried to build a DVI and SVG using
and the same
latex
anddvisvgm
that WW uses. But I can't reproduce the issue this way (the SVG source does not have absurd height.) I'm not entirely sure the above .tex is what PG builds from though.The text was updated successfully, but these errors were encountered: