Changing legend text size coefplot - legend

I am working on coefplot and I would like to readjust the legend size of the labels to vsmall. However, when I use labsize(vsmall)). I get an error. Am I missing a specific step within coefplot?
coefplot weight height, xtitle(Medical Records) ytitle(Share) ///
vertical recast(bar) barwidth(0.15) finten(60) plotlabels("male" "female" "child" ///
"adult", labsize(vsmall)) graphregion(color(white)) bgcolor(white)
Thank you.

you will want to remove labsize(vsmall) from your command entirely, and add legend(size(vsmall)) to the end of your command as an option. Your final command should look like this:
coefplot weight height, xtitle(Medical Records) ytitle(Share) vertical recast(bar) barwidth(0.15) finten(60) plotlabels("male" "female" "child" "adult") graphregion(color(white)) bgcolor(white) legend(size(vsmall))

Related

Matplotlib bar chart different colors for each bar

I am trying to create a simple horizontal bar chart but I want to spruce it up with each bar using a teams color. I thought it would be as simple as passing each teams hex color to the color parameter as an array but what I get is each bar displaying as the first color provided in the array.
data.plot(kind="barh", color=['#A71930', '#DF4601', '#AB0003', '#003278', '#FF5910', '#0E3386', '#BA0021', '#E81828', '#473729', '#D31145', '#0C2340', '#005A9C', '#BD3039', '#EB6E1F', '#C41E3A', '#33006F', '#C6011F', '#004687', '#CE1141', '#134A8E', '#27251F', '#FDB827', '#0C2340', '#FD5A1E', '#00A3E0', '#ffc52f', '#003831', '#005C5C', '#E31937', '#8FBCE6'])
plt.title('Team Ranking Marginal Doller Spent per Marginal Win')
plt.ylabel('Team')
plt.xlabel('Marginal Doller Spent per Marginal Win')
plt.style.use('fivethirtyeight')
plt.gcf().set_size_inches(10, 12)
plt.show()
Here is the result
It looks like you are using pandas to plot, which returns an axis object. You can modify the color of each bar by iterating through the patches:
colors=['#A71930', '#DF4601', '#AB0003', '#003278', '#FF5910', '#0E3386', '#BA0021', '#E81828', '#473729', '#D31145', '#0C2340', '#005A9C', '#BD3039', '#EB6E1F', '#C41E3A', '#33006F', '#C6011F', '#004687', '#CE1141', '#134A8E', '#27251F', '#FDB827', '#0C2340', '#FD5A1E', '#00A3E0', '#ffc52f', '#003831', '#005C5C', '#E31937', '#8FBCE6']
ax=data.plot(kind='barh')
for patch,color in zip(ax.patches,colors):
patch.set_facecolor(color)
It's a bit of a work around, but its nice to get to know how to access the pandas generated figures in case the built-in functions leave something to be desired.
(Edited a variable name because someone in the comments said it was ugly)

The addition of two values in an equation but error occurred

const Rft = ((tubeOuterD * tubeFF / tubeInnerD) + shellFF)
setTotalFoolingResistance(Rft)
[enter image description here][1]
[1]: https://i.stack.imgur.com/IgD2w.jpg
So the problem is that when I tried to add the above two values together, which is 0.00022172949002217295 + 0.0001, instead of the summation of the two values, they linked the both values together instead which is 0.000221729490022172950.0001, which have two decimal point inside. Can I know how I will be able to solve the problem?

simplecart js setting column widths

I've used this site for assistance many times but never had to ask a question so finally joined...anyway, trying to set up simplecart checkout and having some trouble formatting cart output. I have my cart set to table and by default the simpleCart_items class displays the table and it's cells only as wide as they need be to fit the data. I can change this by specifying all cells(columns) as a percentage of the whole table. Unfortunately with 7 columns each only gets about 14% and this is way to much for a 1 or 2 digit quantity and not near big enough for all the characters in the item name without wrapping. What I want is a way to define a different width for each column. I have not found a way to do this even with colgroup but maybe just not doing it right. Any and all help would be appreciated!
Okay, so this may or may not help. This line is located in the simpleCart.js file. I changed it to something simple.
cartColumns : [
{ view: function(item, column){
return"<img src='"+item.get('image')+"' width='250px' height='250px'><br /><center><h3 ><span>"+item.get('name')+"</span></h3><p><a href='javascript:;' class='simpleCart_decrement'><button>-</button></a> "+item.get('quantity')+" <a href='javascript:;' class='simpleCart_increment'><button>+</button></a></p><p>$"+item.get('price')+"</p><p><a href='javascript:;' class='simpleCart_remove remove_icon'><img src='images/icon_x.png' /></a></p></center>";
},
}
],
You can change it to your own html
cartColumns : [
{ view: function(item, column){
return" YOUR HTML HERE ";
},
}
],
It MUST all be in ONE (1) LINE or else it may not work.
here are some values that are used
image = item.get('image')
name = item.get('name')
quantity = item.get('quantity')
price = item.get('price')
you can look at all the values here
http://simplecartjs.org/documentation/displaying_cart_data
but the point is that you can make a cart and display it how you want; with you own html and css. I hope this helped.

JES - Jython - Drawing a line between points on an image

I am working on an assignment where I need to draw a line between points on a map. I built it up using if statements, but that limits how many times I can do something so want to use a loop.
The code I have so far is below, I can add the cities and draw a line, but it draws a line to itself rather than from a start point to the next point (and continue on)
Can anybody please help at all?
def level1():
cityXvalue = [45,95,182,207,256,312,328,350,374,400]
cityYvalue = [310,147,84,201,337,375,434,348,335,265]
# Display the map image
map = makePicture(getMediaPath("map.png"))
show(map)
number = 0
# Ask user to enter numbers of the cities they wish to visit
cities = requestInteger("Enter the number of the city you would like to visit")
# Draw a line between previously entered point and current one
while cities > number:
city = requestInteger("Please choose a city number")
addLine(map,cityXvalue[city],cityYvalue[city], cityXvalue[city], cityYvalue[city])
repaint(map)

PChart - Show a fixed number of lablels in X-Axis

How to show only a fixed number of labels in X-Axis ??
I have tried "LabelSkip", but I think it works only with an interval and not with fixed number of labels.
Here is a print-screen of my chart:
Are you using pChart 1 or pChart2 ?
This can be achived in pChart 1 using setFixedScale
To draw a scale with a maximum value of 10 with 5 points use the following command before drawing the scale
$Graph->setFixedScale(0,10,5);
I know it has been a while since this was asked, but it may help someone:
$maxXLabels = 5; // How many labels on-screen?
$labelSkip = floor( count( $timestamp ) / $maxXLabels ); // how many should we skip?
$myPicture->drawScale(array("LabelSkip"=>$labelSkip));
I have used
"LabelSkip"=>(count($series)/10)
to have 10 labels on the X axis
Works fine for me
Joel Deutscher's answer worked for me. I would have up voted it, but I do not have enough stackoverflow reputation for that.
It works exactly as he said: Chart Width / MinDivHeight = Number of labels on the chart.
Here's my code
$scaleSettings = array("DrawXLines"=>FALSE,"Mode"=>SCALE_MODE_START0,"GridR"=>0,"GridG"=>0,"GridB"=>0,"GridAlpha"=>10,"Pos"=>SCALE_POS_TOPBOTTOM, "MinDivHeight" => 50);
$pchart->chart->drawScale($scaleSettings);