I have a standalone plot which generates an .html file. The file itself is two plots below a title, using the code below, using this suggestion, where p and q are horizontal bar charts:
P = row(p,q)
div = Div(text=overallTitle)
save(column(div,P))
The result is this:
My aim is to centre align the text, so it is above the middle of the two charts, as well as change the font and size of the text. This answer suggests it can be done like this:
div.css_classes = ["my-custom"]
However, now it seems the CSS class "my-custom" needs to be created. This answer suggests (I think) that adding "a Div element with the style sheet" is the way to achieve that.
I have no experience with CSS at all, do I need to create a .css file that is stored in the same directory as the Python script which defines the function that creates the .html file? It may also be worth mentioning that I'd like to keep the .html file output format, I do make use of the interactive features that it provides, e.g. tooltips.
Any help much appreciated.
Related
I am working on a logo on Inkscape and I would like to import it to manim. The file does import properly with all the paths of the SVG but a weird thing is happening.
My code for running the file is this:
class U_letter(Scene):
def construct(self):
letter = SVGMobject("u_letter")
self.add(letter)
letter.set_color(GREEN)
The SVG format of the letter I am trying to add is available here.
It currently has two layers and when importing it this way it displays fine on manim but my problem is that I have to set the fill of the 'inner path'(i.e the inside of the letter) to match the background of the scene and I would like to avoid this.
I tried creating a single path out of the letter by using the difference functionality on Inkscape and that's where my problems started because the final image appears distorted as shown here.
I am however looking for something like this as my final solution. I should also point out that I have been experiencing this behavior with other letters I have tried so far, D and A letters to be exact.
Your help would be greatly appreciated
As of current date (June 3, 2020), There is no "proper" way to import a SVG object, as you see, you can you use SVGMObject and it will work most of the time, but as manim parses the path itself it ignores many things from the SVG specification in it's implementation, so you would have to fix it yourself or wait until it is fixed.
I've been practicing my python/mel coding and have been interested in creating a graph editor. I did a lot of research online and found this previous question (How can I keep an object selected in the outliner after physically deselecting it in the 3d view?) that helped me out a lot. However, I am having an issue were I cannot manually edit the curves that are generated. I'm unsure as to why this is happening and can't seem to find any clear documentation. (I've looked up the command references for mel/python in Maya but it doesn't seem to have detailed explanations).
To be more clear, my goal is to use my mouse to move the curve information based on keyframe data (Exactly like Maya's own graph editor). I am using the code solution from the previous example (edited to include my own selection connections and frame conventions).
So after some research I decided the easiest thing was to use Maya's own graph editor within my interface
# GRAPH ROW
# Section for the graph editor to allow the user to change attributes
paneLayout( configuration='single', parent=form, width=620, height=320 )
# queries Maya's graph editor and places it within my frame
graph = cmds.getPanel(scriptType='graphEditor')
cmds.scriptedPanel( graph[0], e=True, unParent=True)
cmds.scriptedPanel( graph[0], e=True, parent=frame1)
I've been looking for a graphical / ipython console based means to turn lines on and off in a 2D graph generated with matplotlib, but I haven't found anything thus far.
Does anyone know a way to do something like this? What I have in mind specifically is incorporated in MATLAB, and can be seen here:
http://matlab.izmiran.ru/help/techdoc/creating_plots/plot_to5.html
All of the check boxes in the plot browser window will turn the lines on and off; their properties can also be altered graphically in another dialogue box. For now, I've been clicking on the properties button, and setting linetype to none, but this is cumbersome for a graph with many lines...
Thanks Vadim for your answer - you're right that the widgets provide an example with this functionality - to an extent. The example you provide doesn't give the graphical feedback I had in mind; instead, the widgets example closest to my request is actually check_buttons.py (see: http://matplotlib.org/examples/widgets/check_buttons.html)
Here, a side-box of labelled check buttons can be created, where upon clicking the checked buttons, it will turn the lines on and off - see the figure below. I suppose this could be built up into something along the lines of a plot browser like in matlab, but would require additional work to incorporate simple changes to the line style, etc.
I am still interested to know if someone has already done all of the work in making such functionality available; if not, I will post my best attempt when I get around to it.
plot_browser
I don't have sufficient rep points to add the image inline; my apologies.
Yes, there exists module named matplotlib.widgets. There are some example here. It allows you to do exactly what you asked for (source):
I have a django site which is going to display various matplotlib plots. I am able to create a matplotlib plot, convert it into a png and display it,...but only if all the logic is contained within the views.py file of the relevant app.
This would be fine if I just needed a fairly basic page with a simple plot. However the problem is that the site as a whole is going to require several plots each involving their own python files, logic etc.
So what i've done is created a new folder within the app that contains the python files for calculating the various plots. From within the view.py I was planning on just calling the relevant python file which would return the plot. By doing that, I could keep the logic around how the plots are created separate from the displaying of the page.
The problem that i've run into is the following error
QPixmap: It is not safe to use pixmaps outside the GUI thread
After researching this error it is clearly and issue when you are trying to update the GUI from a different thread. However that is not what im trying to do. Im trying to create the plot outside of the views.py file, then pass it back and create the png to update the page. So the updating of the GUI shouldn't be happening in another thread?
My code in views.py is:
fig = plotLogic.getPlot() #this is a call to a separate file which returns the figure
canvas=FigureCanvas(fig)
response=django.http.HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
Is there an alternative way to accomplish what im trying to do? Essentially just keeping the logic of how the plot is created separate and returning the plot so that it can be converted to a png and displayed.
I feel like I am somehow making this more complicated than it should be. Im not intentionally trying to do anything fancy like updating the GUI in a separate thread.
Many thanks.
I am using reportlab to create a pdf with some portait and some landscape pages. The pdf looks great on screen, but when printing it the default print settings are to shrink the pages, rather than rotate them. At first I though that this was just something to do with the settings, but a few other people have commented on it, using a variety of pdf readers and printers. After a bit of investigating it seems that this is something to do with an option set inside the pdf itself, recommending those print settings. Does anyone know of a way to change this when the pdf is generated?