There is this example in my workbook that gives me a list of information and asks to draw a pie chart representing this information. The ONLY module that you can import is turtle. I can draw the pie chart like in figure 1 but I do not know how to separate one segment from all the rest like in figure 2.
Figure 1: http://msenux.redwoods.edu/math/python/graphics/pie2.png
Figure 2: http://www.aecbytes.com/illustrations/viewpoint/2013/issue_67-images/fig11.png
(I realise that figure 2 was created in word)
All I need to know is how to separate just one of the segments with it still being in-line with the whole circle.
Any help would be great
Depends on your design. If the center of the diagram is at the origin, you can add an offset to the coordinates of the section before it's drawn. If, for example, the segment were one quarter of the piechart from 0 to 90 degrees on the unit circle, you could offset the segment along the vector that bisects the section (1,1).
But, if you want some decent feedback, post minimal working code so we can go over it.
Also, if the image you linked is yours, you are waaayyy beyond color-blind.
Related
I am drawing a pie chart out of provided data, and this can potentially get out of hand as the length of the labels can be pretty long, and there can be a lot of them overlapping each other. Because of this, it is crucial to find a good startangle parameter to my pie chart drawing.
Conceptually, I want to use a mouse scroll event to rotate the whole pie chart by 5 degrees every time the user uses the scroll wheel. Rotating the wedges isn't too much trouble with their theta1 and theta2 properties, but repositioning the labels and autotexts is serious trouble because of alignment properties and the lining up with wedges. I also want to retain an interactive frame rate, so clearing the figure and redrawing is not an option.
Here is one such situation where this is useful. The labels are too big and rotating the whole pie chart would help reposition them in sight. Of course in this case it would be enough to resize the chart instead of rotating but you get my point.
Is there a way to achieve this that does not imply rewriting the entire label and autotext positioning code for my own use?
In particular, I'm wondering if it wouldn't be possible to do something that is conceptually equivalent to making the same pyplot.pie call as before, only with a different startangle. Alternatively, maybe Text objects have methods I can use for positioning them around the newly rotated wedges that spare me working with just positions and sizes.
I am making a 3-D Scatterplot with plotly in Python 3 and the Z-axis represents time. I would like to freeze that so that, when the using clicks around to rotate the plot, it spins on that axis, but that axis stays up and down. I'm not sure if it's possible, but that would be a great feature.
As it is, the oldest points are at the top (this is a genetic tree) and the newest are at the bottom. However, it's very easy to get this turned when clicking around the plot to rotate and then the time axis is going left-to-right or diagonal or something and it's a bit disorienting, especially for people who are not used to looking at complex visuals like this (i.e. my intended audience).
A first draft example: https://plot.ly/~seth127/6
Any help is greatly appreciated!
Thanks,
Seth
first question from my side. For the last couple of month self-teaching I have figured out everything using stack overflow and clumsy own designs, but now I am stuck since days:
I use Pynomo to make nomograms with some very fine results. My newest project is to design a circular nomogram using multiple "type 8" conversion charts like in
http://www.myreckonings.com/pynomo/CreatingNomogramsWithPynomo.pdf
starting from page 30.
However I cannot properly line up, or influence how to line up, the circular charts. In the example given the charts mostly shared a common minimum (zero). My functions however (all like AxB+C) do not share a common minimum. I easily manage to distribute the values for each scale in a circle but the circles do not line up at their minima.
Does anyone have an idea or a workaround how I can line up the minimum of scale "32 to 340" with "66 to 285" (for example) so 32 and 66 correspond?
I could provide some example code but I guess the problem is very specific to Pynomo and regular users will know what I am talking about.
to whom it might concern: I figured out a solution. It is clumsy alright, but I am neither a programmer nor mathematician.
I was trying to show 3 different items in one graph as "pie pieces", 110 degrees each, with some space in between (think mercedes benz sign). For each piece a number of circle fragments with scales was to be displayed with a result scale on the outside.
So for item 1, you find find the group you are interested in (circle fragment), draw from bullsey through it to the outer ring and read a result. If you want, repeat for items 2 and 3.
Since all fragments and pieces followed the general formula:
Result = (Measurement x A) + B
I was running into the problem that the circle fragments appeared rotated against each other with one starting at 10 degrees, the other at 113 and so on.
To set each fragment to the correct beginning, therefore forming a nice cake piece, I had to do the following:
determine the dimensions of your cake piece (i chose 110 degrees).
determine your result range, you are interested in (i was only interested in results from 1.5 to 2.0).
calculate for each group in a cake piece the minimum and maximum measurement for the minimum and maximum results.
Subtract the minimum from maximum and divide by the cake piece dimensions (/110 in my case) to give you "units per degree".
Now decide on the starting position of the cake piece (zero is usually "east" position) and calculate the relative degrees to your minimum measurement value as "starting point", for example 45 degrees.
Multiply that number of degrees with the "units per degree". Now you have everything to construct the nomograph pieces. You do not have to fill it in completely, checking your assumptions by applying the numbers to the outer or inner most part should give you a good estimate where everything ends up in the full nomograph.
In my case (one block only):
Center2_params={
'u_min':25.2413,
'u_max':42.4827,
'function_x':lambda u:9*math.cos((math.radians(110/(42.4827-25.2413))*(u+10.025078))),#*2*pi/360*56.4),
'function_y':lambda u:9*math.sin((math.radians(110/(42.4827-25.2413))*(u+10.025078))),#*2*pi/360*56.4),
'title':r'your title here',
'tick_levels':4,
'tick_text_levels':2,
'tick_side':'right',
'axis_color':color.gray(0.10),
'text_color':color.gray(0.10),
'title_color':color.gray(0.10),
}
Center2_block_params={
'block_type':'type_8',
'f_params':Center2_params,
'width':15.0,
'height':15.0,
}
Read up on circle coordinates if needed.
As in the pdf example, I included a bullseye center. I could have displayed all pieces in one nomogram but instead created 3 single nomograms and imported them from pdf into GIMP where I combined them (select by color - click white- pick "selection - invert", copy and paste as new layer.
If you go this route make sure to uncommen the "scale paper" option:
'transformations':[('rotate',0.01)],#('scale paper',)],
Since this option tries to optimally use all the paper, producing curvy nomograms from the pie piece. This looks cool and more sophisticated, but makes combining 3 Nomograms a pain. By uncommenting you get nice pieces. Overlay them bullseye in GIMP, if necessary rotate the pieces with the rotate tool. Make sure to move the pivot point on the bullseye.
Hope this helps anybody.
PS: note that in this nomogram style, all scales are independent (basically overlayed with ticks pointing to left and right), so nothing "automatically follows)
I'm plotting netowrk graphs (Water distribution networks) using bokeh and or matplotlib. From the reference software the plots look like this:
As you can see pumps and water towers have their own little symbols.
I'm using matplotlib and bokeh to plot the same graphs (with a little more info on the system state):
As you can see we have squares and triangles as symbols now. So I would like to either add my own symbols based on some vector graphic of the symbols in the first plot, or at least rotate the triangles to be aligned with the arcs, such that they point along them. Any ideas on how to achieve either? I find the bokeh documentation rather confusing (as you can tell I'm a civil engineer not a programmer)
Instead of rotating the triangle, you may consider arrows.
If you really want to rotate the triangle, I normally rotate the three points of the triangle around its center (by rotation matrix).
About custom symbols, I have never import any external symbols into my matplotlib figure. I usually create the symbol as a polygon and then draw it using the polygon patches.
Hope it helps.
I am working on a few of my meteorology plots and I am trying to make them a little more visually friendly. The polar plot is called a hodograph and plots the windspeed vectors with increasing height. I want to make it so that the lowest 3 kilometers of data is say red, then 3-6km is say blue and such. Ive looked at possibly building my own coolor map but I am not sure how to go about implementing that. Any help would be much appreciated. Ive included a few screenshots and the basic hodograph code. The data used is simply an array with several columns: temperature, wind speed, wind direction, dewpoint, height in meters, ect.
#begin hodograph subplot
ax1 = fig.add_subplot(122,polar = True)
ax1.set_theta_offset(np.pi/2)
ax1.set_theta_direction(-1)
ax1.plot(wd,ws,'ro-')
I was able to figure out with help from a friend how to loop over that data and separate it with a loop. Once separated, each line segment gets plotted independently.