1&&\"string\"==typeof v&&!d.checkClone&&je.test(v))return e.each((function(i){var o=e.eq(i);y&&(t[0]=v.call(this,i,o.html())),Me(o,t,n,r)}));if(p&&(a=(i=be(t,e[0].ownerDocument,!1,e,r)).firstChild,1===i.childNodes.length&&(i=a),a||r)){for(u=(s=w.map(ye(i,\"script\"),He)).length;f0&&me(a,!u&&ye(e,\"script\")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(V(n)){if(t=n[Y.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[Y.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return $(this,(function(e){return void 0===e?w.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Me(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)}))},prepend:function(){return Me(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Me(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Me(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent=\"\");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return w.clone(this,e,t)}))},html:function(e){return $(this,(function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if(\"string\"==typeof e&&!De.test(e)&&!ve[(he.exec(e)||[\"\",\"\"])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n3,re.removeChild(t)),s}}))}();var Ue=[\"Webkit\",\"Moz\",\"ms\"],Xe=v.createElement(\"div\").style,Ve={};function Ge(e){var t=w.cssProps[e]||Ve[e];return t||(e in Xe?e:Ve[e]=function(e){for(var t=e[0].toUpperCase()+e.slice(1),n=Ue.length;n--;)if((e=Ue[n]+t)in Xe)return e}(e)||e)}var Ye=/^(none|table(?!-c[ea]).+)/,Qe=/^--/,Je={position:\"absolute\",visibility:\"hidden\",display:\"block\"},Ke={letterSpacing:\"0\",fontWeight:\"400\"};function Ze(e,t,n){var r=te.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||\"px\"):t}function et(e,t,n,r,i,o){var a=\"width\"===t?1:0,s=0,u=0;if(n===(r?\"border\":\"content\"))return 0;for(;a<4;a+=2)\"margin\"===n&&(u+=w.css(e,n+ne[a],!0,i)),r?(\"content\"===n&&(u-=w.css(e,\"padding\"+ne[a],!0,i)),\"margin\"!==n&&(u-=w.css(e,\"border\"+ne[a]+\"Width\",!0,i))):(u+=w.css(e,\"padding\"+ne[a],!0,i),\"padding\"!==n?u+=w.css(e,\"border\"+ne[a]+\"Width\",!0,i):s+=w.css(e,\"border\"+ne[a]+\"Width\",!0,i));return!r&&o>=0&&(u+=Math.max(0,Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u}function tt(e,t,n){var r=Fe(e),i=(!d.boxSizingReliable()||n)&&\"border-box\"===w.css(e,\"boxSizing\",!1,r),o=i,a=_e(e,t,r),s=\"offset\"+t[0].toUpperCase()+t.slice(1);if(We.test(a)){if(!n)return a;a=\"auto\"}return(!d.boxSizingReliable()&&i||!d.reliableTrDimensions()&&A(e,\"tr\")||\"auto\"===a||!parseFloat(a)&&\"inline\"===w.css(e,\"display\",!1,r))&&e.getClientRects().length&&(i=\"border-box\"===w.css(e,\"boxSizing\",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+et(e,t,n||(i?\"border\":\"content\"),o,r,a)+\"px\"}function nt(e,t,n,r,i){return new nt.prototype.init(e,t,n,r,i)}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=_e(e,\"opacity\");return\"\"===n?\"1\":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=X(t),u=Qe.test(t),l=e.style;if(u||(t=Ge(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&\"get\"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];\"string\"===(o=typeof n)&&(i=te.exec(n))&&i[1]&&(n=se(e,t,i),o=\"number\"),null!=n&&n==n&&(\"number\"!==o||u||(n+=i&&i[3]||(w.cssNumber[s]?\"\":\"px\")),d.clearCloneStyle||\"\"!==n||0!==t.indexOf(\"background\")||(l[t]=\"inherit\"),a&&\"set\"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=X(t);return Qe.test(t)||(t=Ge(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&\"get\"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=_e(e,t,r)),\"normal\"===i&&t in Ke&&(i=Ke[t]),\"\"===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each([\"height\",\"width\"],(function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!Ye.test(w.css(e,\"display\"))||e.getClientRects().length&&e.getBoundingClientRect().width?tt(e,t,r):Be(e,Je,(function(){return tt(e,t,r)}))},set:function(e,n,r){var i,o=Fe(e),a=!d.scrollboxSize()&&\"absolute\"===o.position,s=(a||r)&&\"border-box\"===w.css(e,\"boxSizing\",!1,o),u=r?et(e,t,r,s,o):0;return s&&a&&(u-=Math.ceil(e[\"offset\"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-et(e,t,\"border\",!1,o)-.5)),u&&(i=te.exec(n))&&\"px\"!==(i[3]||\"px\")&&(e.style[t]=n,n=w.css(e,t)),Ze(0,n,u)}}})),w.cssHooks.marginLeft=ze(d.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(_e(e,\"marginLeft\"))||e.getBoundingClientRect().left-Be(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+\"px\"})),w.each({margin:\"\",padding:\"\",border:\"Width\"},(function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o=\"string\"==typeof n?n.split(\" \"):[n];r<4;r++)i[e+ne[r]+t]=o[r]||o[r-2]||o[0];return i}},\"margin\"!==e&&(w.cssHooks[e+t].set=Ze)})),w.fn.extend({css:function(e,t){return $(this,(function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=Fe(e),i=t.length;a1)}}),w.Tween=nt,nt.prototype={constructor:nt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?\"\":\"px\")},cur:function(){var e=nt.propHooks[this.prop];return e&&e.get?e.get(this):nt.propHooks._default.get(this)},run:function(e){var t,n=nt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):nt.propHooks._default.set(this),this}},nt.prototype.init.prototype=nt.prototype,nt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,\"\"))&&\"auto\"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||!w.cssHooks[e.prop]&&null==e.elem.style[Ge(e.prop)]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},nt.propHooks.scrollTop=nt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:\"swing\"},w.fx=nt.prototype.init,w.fx.step={};var rt,it,ot=/^(?:toggle|show|hide)$/,at=/queueHooks$/;function st(){it&&(!1===v.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(st):e.setTimeout(st,w.fx.interval),w.fx.tick())}function ut(){return e.setTimeout((function(){rt=void 0})),rt=Date.now()}function lt(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i[\"margin\"+(n=ne[r])]=i[\"padding\"+n]=e;return t&&(i.opacity=i.width=e),i}function ct(e,t,n){for(var r,i=(ft.tweeners[t]||[]).concat(ft.tweeners[\"*\"]),o=0,a=i.length;o1)},removeAttr:function(e){return this.each((function(){w.removeAttr(this,e)}))}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?pt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&\"set\"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+\"\"),n):i&&\"get\"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!d.radioValue&&\"radio\"===t&&A(e,\"input\")){var n=e.value;return e.setAttribute(\"type\",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(P);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),pt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\\w+/g),(function(e,t){var n=dt[t]||w.find.attr;dt[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=dt[a],dt[a]=i,i=null!=n(e,t,r)?a:null,dt[a]=o),i}}));var ht=/^(?:input|select|textarea|button)$/i,gt=/^(?:a|area)$/i;function vt(e){return(e.match(P)||[]).join(\" \")}function yt(e){return e.getAttribute&&e.getAttribute(\"class\")||\"\"}function mt(e){return Array.isArray(e)?e:\"string\"==typeof e&&e.match(P)||[]}w.fn.extend({prop:function(e,t){return $(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[w.propFix[e]||e]}))}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&\"set\"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&\"get\"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,\"tabindex\");return t?parseInt(t,10):ht.test(e.nodeName)||gt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:\"htmlFor\",class:\"className\"}}),d.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each([\"tabIndex\",\"readOnly\",\"maxLength\",\"cellSpacing\",\"cellPadding\",\"rowSpan\",\"colSpan\",\"useMap\",\"frameBorder\",\"contentEditable\"],(function(){w.propFix[this.toLowerCase()]=this})),w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(h(e))return this.each((function(t){w(this).addClass(e.call(this,t,yt(this)))}));if((t=mt(e)).length)for(;n=this[u++];)if(i=yt(n),r=1===n.nodeType&&\" \"+vt(i)+\" \"){for(a=0;o=t[a++];)r.indexOf(\" \"+o+\" \")<0&&(r+=o+\" \");i!==(s=vt(r))&&n.setAttribute(\"class\",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(h(e))return this.each((function(t){w(this).removeClass(e.call(this,t,yt(this)))}));if(!arguments.length)return this.attr(\"class\",\"\");if((t=mt(e)).length)for(;n=this[u++];)if(i=yt(n),r=1===n.nodeType&&\" \"+vt(i)+\" \"){for(a=0;o=t[a++];)for(;r.indexOf(\" \"+o+\" \")>-1;)r=r.replace(\" \"+o+\" \",\" \");i!==(s=vt(r))&&n.setAttribute(\"class\",s)}return this},toggleClass:function(e,t){var n=typeof e,r=\"string\"===n||Array.isArray(e);return\"boolean\"==typeof t&&r?t?this.addClass(e):this.removeClass(e):h(e)?this.each((function(n){w(this).toggleClass(e.call(this,n,yt(this),t),t)})):this.each((function(){var t,i,o,a;if(r)for(i=0,o=w(this),a=mt(e);t=a[i++];)o.hasClass(t)?o.removeClass(t):o.addClass(t);else void 0!==e&&\"boolean\"!==n||((t=yt(this))&&Y.set(this,\"__className__\",t),this.setAttribute&&this.setAttribute(\"class\",t||!1===e?\"\":Y.get(this,\"__className__\")||\"\"))}))},hasClass:function(e){var t,n,r=0;for(t=\" \"+e+\" \";n=this[r++];)if(1===n.nodeType&&(\" \"+vt(yt(n))+\" \").indexOf(t)>-1)return!0;return!1}});var xt=/\\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];return arguments.length?(r=h(e),this.each((function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i=\"\":\"number\"==typeof i?i+=\"\":Array.isArray(i)&&(i=w.map(i,(function(e){return null==e?\"\":e+\"\"}))),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&\"set\"in t&&void 0!==t.set(this,i,\"value\")||(this.value=i))}))):i?(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&\"get\"in t&&void 0!==(n=t.get(i,\"value\"))?n:\"string\"==typeof(n=i.value)?n.replace(xt,\"\"):null==n?\"\":n:void 0}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,\"value\");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a=\"select-one\"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each([\"radio\",\"checkbox\"],(function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},d.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute(\"value\")?\"on\":e.value})})),d.focusin=\"onfocusin\"in e;var bt=/^(?:focusinfocus|focusoutblur)$/,wt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,r,i){var o,a,s,u,l,f,p,d,y=[r||v],m=c.call(t,\"type\")?t.type:t,x=c.call(t,\"namespace\")?t.namespace.split(\".\"):[];if(a=d=s=r=r||v,3!==r.nodeType&&8!==r.nodeType&&!bt.test(m+w.event.triggered)&&(m.indexOf(\".\")>-1&&(x=m.split(\".\"),m=x.shift(),x.sort()),l=m.indexOf(\":\")<0&&\"on\"+m,(t=t[w.expando]?t:new w.Event(m,\"object\"==typeof t&&t)).isTrigger=i?2:3,t.namespace=x.join(\".\"),t.rnamespace=t.namespace?new RegExp(\"(^|\\\\.)\"+x.join(\"\\\\.(?:.*\\\\.|)\")+\"(\\\\.|$)\"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:w.makeArray(n,[t]),p=w.event.special[m]||{},i||!p.trigger||!1!==p.trigger.apply(r,n))){if(!i&&!p.noBubble&&!g(r)){for(u=p.delegateType||m,bt.test(u+m)||(a=a.parentNode);a;a=a.parentNode)y.push(a),s=a;s===(r.ownerDocument||v)&&y.push(s.defaultView||s.parentWindow||e)}for(o=0;(a=y[o++])&&!t.isPropagationStopped();)d=a,t.type=o>1?u:p.bindType||m,(f=(Y.get(a,\"events\")||Object.create(null))[t.type]&&Y.get(a,\"handle\"))&&f.apply(a,n),(f=l&&a[l])&&f.apply&&V(a)&&(t.result=f.apply(a,n),!1===t.result&&t.preventDefault());return t.type=m,i||t.isDefaultPrevented()||p._default&&!1!==p._default.apply(y.pop(),n)||!V(r)||l&&h(r[m])&&!g(r)&&((s=r[l])&&(r[l]=null),w.event.triggered=m,t.isPropagationStopped()&&d.addEventListener(m,wt),r[m](),t.isPropagationStopped()&&d.removeEventListener(m,wt),w.event.triggered=void 0,s&&(r[l]=s)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each((function(){w.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),d.focusin||w.each({focus:\"focusin\",blur:\"focusout\"},(function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this.document||this,i=Y.access(r,t);i||r.addEventListener(e,n,!0),Y.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this.document||this,i=Y.access(r,t)-1;i?Y.access(r,t,i):(r.removeEventListener(e,n,!0),Y.remove(r,t))}}}));var Tt=e.location,Ct={guid:Date.now()},Et=/\\?/;w.parseXML=function(t){var n;if(!t||\"string\"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,\"text/xml\")}catch(e){n=void 0}return n&&!n.getElementsByTagName(\"parsererror\").length||w.error(\"Invalid XML: \"+t),n};var St=/\\[\\]$/,kt=/\\r?\\n/g,At=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;function Dt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,(function(t,i){n||St.test(e)?r(e,i):Dt(e+\"[\"+(\"object\"==typeof i&&null!=i?t:\"\")+\"]\",i,n,r)}));else if(n||\"object\"!==x(t))r(e,t);else for(i in t)Dt(e+\"[\"+i+\"]\",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=h(t)?t():t;r[r.length]=encodeURIComponent(e)+\"=\"+encodeURIComponent(null==n?\"\":n)};if(null==e)return\"\";if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,(function(){i(this.name,this.value)}));else for(n in e)Dt(n,e[n],t,i);return r.join(\"&\")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=w.prop(this,\"elements\");return e?w.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!w(this).is(\":disabled\")&&Nt.test(this.nodeName)&&!At.test(e)&&(this.checked||!de.test(e))})).map((function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,(function(e){return{name:t.name,value:e.replace(kt,\"\\r\\n\")}})):{name:t.name,value:n.replace(kt,\"\\r\\n\")}})).get()}});var jt=/%20/g,qt=/#.*$/,Lt=/([?&])_=[^&]*/,Ht=/^(.*?):[ \\t]*([^\\r\\n]*)$/gm,Ot=/^(?:GET|HEAD)$/,Pt=/^\\/\\//,Rt={},Mt={},It=\"*/\".concat(\"*\"),Wt=v.createElement(\"a\");function Ft(e){return function(t,n){\"string\"!=typeof t&&(n=t,t=\"*\");var r,i=0,o=t.toLowerCase().match(P)||[];if(h(n))for(;r=o[i++];)\"+\"===r[0]?(r=r.slice(1)||\"*\",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function Bt(e,t,n,r){var i={},o=e===Mt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],(function(e,s){var l=s(t,n,r);return\"string\"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)})),u}return a(t.dataTypes[0])||!i[\"*\"]&&a(\"*\")}function $t(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}Wt.href=Tt.href,w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Tt.href,type:\"GET\",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Tt.protocol),global:!0,processData:!0,async:!0,contentType:\"application/x-www-form-urlencoded; charset=UTF-8\",accepts:{\"*\":It,text:\"text/plain\",html:\"text/html\",xml:\"application/xml, text/xml\",json:\"application/json, text/javascript\"},contents:{xml:/\\bxml\\b/,html:/\\bhtml/,json:/\\bjson\\b/},responseFields:{xml:\"responseXML\",text:\"responseText\",json:\"responseJSON\"},converters:{\"* text\":String,\"text html\":!0,\"text json\":JSON.parse,\"text xml\":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?$t($t(e,w.ajaxSettings),t):$t(w.ajaxSettings,e)},ajaxPrefilter:Ft(Rt),ajaxTransport:Ft(Mt),ajax:function(t,n){\"object\"==typeof t&&(n=t,t=void 0),n=n||{};var r,i,o,a,s,u,l,c,f,p,d=w.ajaxSetup({},n),h=d.context||d,g=d.context&&(h.nodeType||h.jquery)?w(h):w.event,y=w.Deferred(),m=w.Callbacks(\"once memory\"),x=d.statusCode||{},b={},T={},C=\"canceled\",E={readyState:0,getResponseHeader:function(e){var t;if(l){if(!a)for(a={};t=Ht.exec(o);)a[t[1].toLowerCase()+\" \"]=(a[t[1].toLowerCase()+\" \"]||[]).concat(t[2]);t=a[e.toLowerCase()+\" \"]}return null==t?null:t.join(\", \")},getAllResponseHeaders:function(){return l?o:null},setRequestHeader:function(e,t){return null==l&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==l&&(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(l)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return r&&r.abort(t),S(0,t),this}};if(y.promise(E),d.url=((t||d.url||Tt.href)+\"\").replace(Pt,Tt.protocol+\"//\"),d.type=n.method||n.type||d.method||d.type,d.dataTypes=(d.dataType||\"*\").toLowerCase().match(P)||[\"\"],null==d.crossDomain){u=v.createElement(\"a\");try{u.href=d.url,u.href=u.href,d.crossDomain=Wt.protocol+\"//\"+Wt.host!=u.protocol+\"//\"+u.host}catch(e){d.crossDomain=!0}}if(d.data&&d.processData&&\"string\"!=typeof d.data&&(d.data=w.param(d.data,d.traditional)),Bt(Rt,d,n,E),l)return E;for(f in(c=w.event&&d.global)&&0==w.active++&&w.event.trigger(\"ajaxStart\"),d.type=d.type.toUpperCase(),d.hasContent=!Ot.test(d.type),i=d.url.replace(qt,\"\"),d.hasContent?d.data&&d.processData&&0===(d.contentType||\"\").indexOf(\"application/x-www-form-urlencoded\")&&(d.data=d.data.replace(jt,\"+\")):(p=d.url.slice(i.length),d.data&&(d.processData||\"string\"==typeof d.data)&&(i+=(Et.test(i)?\"&\":\"?\")+d.data,delete d.data),!1===d.cache&&(i=i.replace(Lt,\"$1\"),p=(Et.test(i)?\"&\":\"?\")+\"_=\"+Ct.guid+++p),d.url=i+p),d.ifModified&&(w.lastModified[i]&&E.setRequestHeader(\"If-Modified-Since\",w.lastModified[i]),w.etag[i]&&E.setRequestHeader(\"If-None-Match\",w.etag[i])),(d.data&&d.hasContent&&!1!==d.contentType||n.contentType)&&E.setRequestHeader(\"Content-Type\",d.contentType),E.setRequestHeader(\"Accept\",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(\"*\"!==d.dataTypes[0]?\", \"+It+\"; q=0.01\":\"\"):d.accepts[\"*\"]),d.headers)E.setRequestHeader(f,d.headers[f]);if(d.beforeSend&&(!1===d.beforeSend.call(h,E,d)||l))return E.abort();if(C=\"abort\",m.add(d.complete),E.done(d.success),E.fail(d.error),r=Bt(Mt,d,n,E)){if(E.readyState=1,c&&g.trigger(\"ajaxSend\",[E,d]),l)return E;d.async&&d.timeout>0&&(s=e.setTimeout((function(){E.abort(\"timeout\")}),d.timeout));try{l=!1,r.send(b,S)}catch(e){if(l)throw e;S(-1,e)}}else S(-1,\"No Transport\");function S(t,n,a,u){var f,p,v,b,T,C=n;l||(l=!0,s&&e.clearTimeout(s),r=void 0,o=u||\"\",E.readyState=t>0?4:0,f=t>=200&&t<300||304===t,a&&(b=function(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;\"*\"===u[0];)u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader(\"Content-Type\"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+\" \"+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(d,E,a)),!f&&w.inArray(\"script\",d.dataTypes)>-1&&(d.converters[\"text script\"]=function(){}),b=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if(\"*\"===o)o=u;else if(\"*\"!==u&&u!==o){if(!(a=l[u+\" \"+o]||l[\"* \"+o]))for(i in l)if((s=i.split(\" \"))[1]===o&&(a=l[u+\" \"+s[0]]||l[\"* \"+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:\"parsererror\",error:a?e:\"No conversion from \"+u+\" to \"+o}}}return{state:\"success\",data:t}}(d,b,E,f),f?(d.ifModified&&((T=E.getResponseHeader(\"Last-Modified\"))&&(w.lastModified[i]=T),(T=E.getResponseHeader(\"etag\"))&&(w.etag[i]=T)),204===t||\"HEAD\"===d.type?C=\"nocontent\":304===t?C=\"notmodified\":(C=b.state,p=b.data,f=!(v=b.error))):(v=C,!t&&C||(C=\"error\",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+\"\",f?y.resolveWith(h,[p,C,E]):y.rejectWith(h,[E,C,v]),E.statusCode(x),x=void 0,c&&g.trigger(f?\"ajaxSuccess\":\"ajaxError\",[E,d,f?p:v]),m.fireWith(h,[E,C]),c&&(g.trigger(\"ajaxComplete\",[E,d]),--w.active||w.event.trigger(\"ajaxStop\")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,\"json\")},getScript:function(e,t){return w.get(e,void 0,t,\"script\")}}),w.each([\"get\",\"post\"],(function(e,t){w[t]=function(e,n,r,i){return h(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}})),w.ajaxPrefilter((function(e){var t;for(t in e.headers)\"content-type\"===t.toLowerCase()&&(e.contentType=e.headers[t]||\"\")})),w._evalUrl=function(e,t,n){return w.ajax({url:e,type:\"GET\",dataType:\"script\",cache:!0,async:!1,global:!1,converters:{\"text script\":function(){}},dataFilter:function(e){w.globalEval(e,t,n)}})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(h(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return h(e)?this.each((function(t){w(this).wrapInner(e.call(this,t))})):this.each((function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)}))},wrap:function(e){var t=h(e);return this.each((function(n){w(this).wrapAll(t?e.call(this,n):e)}))},unwrap:function(e){return this.parent(e).not(\"body\").each((function(){w(this).replaceWith(this.childNodes)})),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var _t={0:200,1223:204},zt=w.ajaxSettings.xhr();d.cors=!!zt&&\"withCredentials\"in zt,d.ajax=zt=!!zt,w.ajaxTransport((function(t){var n,r;if(d.cors||zt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];for(a in t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i[\"X-Requested-With\"]||(i[\"X-Requested-With\"]=\"XMLHttpRequest\"),i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,\"abort\"===e?s.abort():\"error\"===e?\"number\"!=typeof s.status?o(0,\"error\"):o(s.status,s.statusText):o(_t[s.status]||s.status,s.statusText,\"text\"!==(s.responseType||\"text\")||\"string\"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n(\"error\"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout((function(){n&&r()}))},n=n(\"abort\");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}})),w.ajaxPrefilter((function(e){e.crossDomain&&(e.contents.script=!1)})),w.ajaxSetup({accepts:{script:\"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript\"},contents:{script:/\\b(?:java|ecma)script\\b/},converters:{\"text script\":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter(\"script\",(function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type=\"GET\")})),w.ajaxTransport(\"script\",(function(e){var t,n;if(e.crossDomain||e.scriptAttrs)return{send:function(r,i){t=w(\""
],
"text/plain": [
":Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 3,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "1003"
}
},
"output_type": "execute_result"
}
],
"source": [
"df_2012 = df.loc[df['year']==2012, :].copy()\n",
"\n",
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Specification of the element type\n",
"\n",
"We used `hv.Points` to invoke an **element of visualization**. An element is just a way of converting the tabular nature of the data to a graphical representation, in this case a scatter plot of points. That is, we want to make a plot where each glyph lies in a two-dimensional plot and the values of both the x- and y-axes are independent. (This is contrasted with `hv.Scatter` in which the x-coordinate is the independent variable and the y-coordinate is dependent on x; `hv.Points` is more appropriate here.)\n",
"\n",
"The available element types may be found in the [HoloViews reference gallery](http://holoviews.org/reference/index.html)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Specification of dimensions\n",
"\n",
"There are two types of dimensions, **key dimensions** and **value dimensions**, specified with the `kdims` and `vdims` arguments, respectively. You can think of key and value dimensions like keys and values of a dictionary (where you can have multidimensional keys). Key dimensions are indexing dimensions, which say where on the graphic the data in a row will reside. The value dimensions give information about each data point. In the simple plot above, the key dimensions are the the beak length and beak depth. Those columns determined where the glyphs were placed.\n",
"\n",
"We additionally had a value dimension, specified by `vdims`, which has additional information associated with each data point. This information was not used in the above plot, but we will put it to use momentarily."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Stylizing plots\n",
"\n",
"After a plotting Element is specified, we can stylize it using the `hv.opts` functionality. To investigate what styling options are available for each kind of plotting element, you can enter, for example\n",
"\n",
"```python\n",
"hv.help(hv.Points)\n",
"```\n",
"\n",
"and you will get detailed information on what options are available for stylizing `hv.Points` elements. Let's try a different styling for the above plot using `.opts()`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 4,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "1123"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
").opts(\n",
" alpha=0.7,\n",
" color='#1f77b3',\n",
" frame_height=200,\n",
" frame_width=200,\n",
" show_grid=True,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"I find the HoloViews defaults not very pleasing.\n",
"\n",
"If you agree and want to define defaults for an entire document, you may do so using `hv.opts.defaults()`. I have made some defaults that I find more pleasing that are available in the `bootcamp_utils.hv_defaults.set_defaults()` function. Let's set those defaults (which will be active for the rest of the notebook), and see how our plot looks.\n",
"\n",
"**Warning:** Setting the defaults in this way may affect some styling in more complex plots in unexpected ways. If you want more fine-grained control of each plot, I would recommend not setting the defaults and rather using `.opts()` for each plot."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 5,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "1245"
}
},
"output_type": "execute_result"
}
],
"source": [
"bootcamp_utils.hv_defaults.set_defaults()\n",
"\n",
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Grouping by value dimensions\n",
"\n",
"Recall that we have an unused value dimension in the element we created. We would naturally like to separate out the glyphs by species. To do this, we can do a `groupby` operation on the Element. That's right, we can do groupby operations on graphical elements!"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":HoloMap [species]\n",
" :Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 6,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "1367"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
").groupby(\n",
" 'species'\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now have a pull down menu to the right of the plot where we can select the species we want and the glyphs on the plot will adjust accordingly. By default, after applying the groupby operation, HoloViews gives us a **HoloMap object**. The values in the column we used to group by are now selectable through a graphical interface (a pull-down menu).\n",
"\n",
"We may instead with to group by species and lay the plots out next to each other, creating a **layout**. We can use the `layout()` method do to this."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":NdLayout [species]\n",
" :Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 7,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "1539"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
").groupby(\n",
" 'species'\n",
").opts(\n",
" frame_height=225,\n",
" frame_width=225,\n",
").layout(\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, we may wish to **overlay** the plots for each species that we split by species."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":NdOverlay [species]\n",
" :Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 8,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "1943"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
").groupby(\n",
" 'species'\n",
").opts(\n",
" frame_height=225,\n",
" frame_width=225,\n",
").overlay(\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"HoloViews was kind enough to automatically provide us with a (clickable) legend!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further stylizing\n",
"\n",
"We can use `.opts()` to add tooltips where we can hover and get additional information from the vdims."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":NdOverlay [species]\n",
" :Points [beak length (mm),beak depth (mm)] (species)"
]
},
"execution_count": 9,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "2197"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Points(\n",
" data=df_2012,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species'],\n",
").groupby(\n",
" 'species'\n",
").opts(\n",
" tools=['hover']\n",
").overlay(\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As a final example of constructing this plot, let's consider the entire data set and allow the year to be selected via a HoloMap, but color by species for each year."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":HoloMap [year]\n",
" :NdOverlay [species]\n",
" :Points [beak length (mm),beak depth (mm)] (species,year)"
]
},
"execution_count": 10,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "2454"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Points(\n",
" data=df,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species', 'year'],\n",
").groupby(\n",
" ['species', 'year'],\n",
").opts(\n",
" tools=['hover'],\n",
").overlay(\n",
" 'species',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Saving a HoloViews plot\n",
"\n",
"You can save a HoloViews plot (or layout, HoloMap, etc.) using the `hv.save()` function. The `hv.save()` function is smart; it will determine how you want to save your HoloViews object based on the suffix of the output file name.\n",
"\n",
"As an example, we can make the above plot again, but this time not displaying in the notebook, but rather storing it as a variable."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"finch_plot = hv.Points(\n",
" data=df,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species', 'year'],\n",
").groupby(\n",
" ['species', 'year'],\n",
").opts(\n",
" tools=['hover'],\n",
").overlay(\n",
" 'species',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we can use `hv.save()` to write this plot to disk as an HTML file."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \r"
]
}
],
"source": [
"hv.save(finch_plot, 'finch_plot.html')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When we open `finch_plot.html`, the result is a fully interactive plot, self-contained in the HTML file. This file can be emailed to a colleague or even embedded in a publication.\n",
"\n",
"When discuss **dashboarding** in a [future lesson](l29_dashboards.ipynb), we will see that we can make even more elaborate, informative interactive plots, though exporting these to standalone HTML is more challenging."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Extracting the Bokeh plotting object\n",
"\n",
"After making and displaying a HoloViews plot, we might want to get the Bokeh figure. We can extract that using `hv.render()`."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"2bd2da39-36dd-4438-be9c-611fea98dc1a\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"3630\"}],\"center\":[{\"id\":\"3633\"},{\"id\":\"3637\"}],\"height\":350,\"left\":[{\"id\":\"3634\"}],\"margin\":null,\"min_border_bottom\":10,\"min_border_left\":10,\"min_border_right\":10,\"min_border_top\":10,\"renderers\":[{\"id\":\"3665\"},{\"id\":\"3674\"}],\"sizing_mode\":\"fixed\",\"title\":{\"id\":\"3622\"},\"toolbar\":{\"id\":\"3644\"},\"toolbar_location\":\"above\",\"width\":450,\"x_range\":{\"id\":\"3617\"},\"x_scale\":{\"id\":\"3626\"},\"y_range\":{\"id\":\"3618\"},\"y_scale\":{\"id\":\"3628\"}},\"id\":\"3621\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.75},\"fill_color\":{\"value\":\"#1f77b3\"},\"line_alpha\":{\"value\":0.75},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3663\",\"type\":\"Scatter\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#1f77b3\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3664\",\"type\":\"Scatter\"},{\"attributes\":{\"source\":{\"id\":\"3659\"}},\"id\":\"3666\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"3628\",\"type\":\"LinearScale\"},{\"attributes\":{\"angle\":{\"value\":0.0},\"fill_alpha\":{\"value\":0.75},\"fill_color\":{\"value\":\"#1f77b3\"},\"hatch_alpha\":{\"value\":1.0},\"hatch_color\":{\"value\":\"black\"},\"hatch_scale\":{\"value\":12.0},\"hatch_weight\":{\"value\":1.0},\"line_alpha\":{\"value\":0.75},\"line_cap\":{\"value\":\"butt\"},\"line_color\":{\"value\":\"#1f77b3\"},\"line_dash\":{\"value\":[]},\"line_dash_offset\":{\"value\":0},\"line_join\":{\"value\":\"bevel\"},\"line_width\":{\"value\":1},\"marker\":{\"value\":\"circle\"},\"size\":{\"value\":4},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3667\",\"type\":\"Scatter\"},{\"attributes\":{},\"id\":\"3639\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"3659\"},\"glyph\":{\"id\":\"3662\"},\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"3664\"},\"nonselection_glyph\":{\"id\":\"3663\"},\"selection_glyph\":{\"id\":\"3667\"},\"view\":{\"id\":\"3666\"}},\"id\":\"3665\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"beak depth (mm)\",\"formatter\":{\"id\":\"3655\"},\"major_label_policy\":{\"id\":\"3656\"},\"ticker\":{\"id\":\"3635\"}},\"id\":\"3634\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"3631\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"3669\",\"type\":\"Selection\"},{\"attributes\":{\"axis\":{\"id\":\"3630\"},\"ticker\":{\"id\":\"3631\"}},\"id\":\"3633\",\"type\":\"Grid\"},{\"attributes\":{\"axis\":{\"id\":\"3634\"},\"dimension\":1,\"ticker\":{\"id\":\"3635\"}},\"id\":\"3637\",\"type\":\"Grid\"},{\"attributes\":{\"active_multi\":null,\"tools\":[{\"id\":\"3619\"},{\"id\":\"3638\"},{\"id\":\"3639\"},{\"id\":\"3640\"},{\"id\":\"3641\"},{\"id\":\"3642\"}]},\"id\":\"3644\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"3640\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"3638\",\"type\":\"SaveTool\"},{\"attributes\":{\"end\":16.28388888888889,\"reset_end\":16.28388888888889,\"reset_start\":8.41611111111111,\"start\":8.41611111111111,\"tags\":[[[\"beak length (mm)\",\"beak length (mm)\",null]]]},\"id\":\"3617\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"3626\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"3643\"}},\"id\":\"3641\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"3668\"}},\"id\":\"3675\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"3642\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"3653\",\"type\":\"AllLabels\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.75},\"fill_color\":{\"value\":\"#1f77b3\"},\"line_alpha\":{\"value\":0.75},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3662\",\"type\":\"Scatter\"},{\"attributes\":{\"callback\":null,\"renderers\":[{\"id\":\"3665\"},{\"id\":\"3674\"}],\"tags\":[\"hv_created\"],\"tooltips\":[[\"species\",\"@{species}\"],[\"beak length (mm)\",\"@{beak_length_left_parenthesis_mm_right_parenthesis}\"],[\"beak depth (mm)\",\"@{beak_depth_left_parenthesis_mm_right_parenthesis}\"],[\"year\",\"@{year}\"]]},\"id\":\"3619\",\"type\":\"HoverTool\"},{\"attributes\":{},\"id\":\"3685\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"3660\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"3652\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"3668\"},\"glyph\":{\"id\":\"3671\"},\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"3673\"},\"nonselection_glyph\":{\"id\":\"3672\"},\"selection_glyph\":{\"id\":\"3676\"},\"view\":{\"id\":\"3675\"}},\"id\":\"3674\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.75},\"fill_color\":{\"value\":\"#ff7e0e\"},\"line_alpha\":{\"value\":0.75},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3671\",\"type\":\"Scatter\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.75},\"fill_color\":{\"value\":\"#ff7e0e\"},\"line_alpha\":{\"value\":0.75},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3672\",\"type\":\"Scatter\"},{\"attributes\":{\"text\":\"year: 1973\"},\"id\":\"3622\",\"type\":\"Title\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#ff7e0e\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3673\",\"type\":\"Scatter\"},{\"attributes\":{\"angle\":{\"value\":0.0},\"fill_alpha\":{\"value\":0.75},\"fill_color\":{\"value\":\"#ff7e0e\"},\"hatch_alpha\":{\"value\":1.0},\"hatch_color\":{\"value\":\"black\"},\"hatch_scale\":{\"value\":12.0},\"hatch_weight\":{\"value\":1.0},\"line_alpha\":{\"value\":0.75},\"line_cap\":{\"value\":\"butt\"},\"line_color\":{\"value\":\"#ff7e0e\"},\"line_dash\":{\"value\":[]},\"line_dash_offset\":{\"value\":0},\"line_join\":{\"value\":\"bevel\"},\"line_width\":{\"value\":1},\"marker\":{\"value\":\"circle\"},\"size\":{\"value\":4},\"x\":{\"field\":\"beak length (mm)\"},\"y\":{\"field\":\"beak depth (mm)\"}},\"id\":\"3676\",\"type\":\"Scatter\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"3643\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"end\":12.989999999999998,\"reset_end\":12.989999999999998,\"reset_start\":6.61,\"start\":6.61,\"tags\":[[[\"beak depth (mm)\",\"beak depth (mm)\",null]]]},\"id\":\"3618\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"3687\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"axis_label\":\"beak length (mm)\",\"formatter\":{\"id\":\"3652\"},\"major_label_policy\":{\"id\":\"3653\"},\"ticker\":{\"id\":\"3631\"}},\"id\":\"3630\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"3655\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data\":{\"beak depth (mm)\":{\"__ndarray__\":\"AAAAAAAAIUDNzMzMzMwhQAAAAAAAAB5AMzMzMzMzI0BmZmZmZmYiQGZmZmZmZiBAMzMzMzMzH0AzMzMzMzMhQM3MzMzMzCBAzczMzMzMHkAAAAAAAAAgQGZmZmZmZiFAMzMzMzMzIECamZmZmZkhQM3MzMzMzCJAAAAAAAAAJEAzMzMzMzMjQDMzMzMzMyNAMzMzMzMzIEAAAAAAAAAeQM3MzMzMzCBAmpmZmZmZH0CamZmZmZkgQM3MzMzMzCFAMzMzMzMzIkDNzM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\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\",\"fortis\"],\"year\":[2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012]},\"selected\":{\"id\":\"3660\"},\"selection_policy\":{\"id\":\"3685\"}},\"id\":\"3659\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"3656\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"3635\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data\":{\"beak depth (mm)\":{\"__ndarray__\":\"zczMzMzMIkAAAAAAAAAjQAAAAAAAACZAZmZmZmZmIUDNzMzMzMwgQDMzMzMzMyJAZmZmZmZmIUBmZmZmZmYkQDMzMzMzMyNAMzMzMzOzIUCamZmZmZkhQAAAAAAAACNAZmZmZmZmIkAAAAAAAAAiQJqZmZmZmSNAmpmZmZmZIkAAAAAAAAAiQGZmZmZmZiRAzczMzMzMHkAAAAAAAAAiQAAAAAAAACNAzczMzMzMIkAAAAAAAAAgQM3MzMzMzCFAzczMzMzMIkAAAAAAAAAjQAAAAAAAACBAAAAAAAAAJEBmZmZmZuYhQGZmZmZmZiBAmpmZmZmZIUBmZmZmZmYiQM3MzMzMzCJAAAAAAAAAI0AzMzMzMzMgQAAAAAAAACNAzczMzMzMIECamZmZmZkiQJqZmZmZmSJAMzMzMzMzI0BmZmZmZmYiQAAAAAAAACRAzczMzMzMIUAAAAAAAAAlQM3MzMzMzCFAMzMzMzMzIUCamZmZmZkhQM3MzMzMTCJAAAAAAAAAI0AzMzMzMzMiQGZmZmZmZiRAzczMzMzMIEAAAAAAAAAkQGZmZmZmZiRAmpmZmZmZIkCamZmZmZklQJqZmZmZmSBAMzMzMzMzH0CamZmZmZkjQJqZmZmZmR9AzczMzMzMIUDNzMzMzMweQM3MzMzMzCFAzczMzMzMIkDNzMzMzMwiQAAAAAAAACFAAAAAAAAAIUAzMzMzMzMjQGZmZmZ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AAsQAAAAAAAACtAmpmZmZmZJ0BmZmZmZmYrQGZmZmZmZipAZmZmZmZmKEAAAAAAAAAqQDMzMzMzMypAZmZmZmZmLUBmZmZmZmYrQAAAAAAAACtAmpmZmZmZKkAzMzMzMzMsQAAAAAAAAClAZmZmZmZmK0AzMzMzMzMtQDMzMzMzMyxAzczMzMzMKUDNzMzMzMwrQM3MzMzMzCpAAAAAAAAAKkBmZmZmZmYpQDMzMzMzMyhAAAAAAAAALEDNzMzMzMwtQM3MzMzMzCtAzczMzMzMKUAzMzMzMzMtQAAAAAAAACxAAAAAAAAAKkBmZmZmZmYpQAAAAAAAACxAMzMzMzMzLEAzMzMzMzMsQAAAAAAAACpAAAAAAAAAK0DNzMzMzMwqQM3MzMzMzCtAMzMzMzMzKkDNzMzMzMwpQAAAAAAAACxAAAAAAAAALEAzMzMzMzMsQGZmZmZmZi1AzczMzMzMKkCamZmZmZkrQM3MzMzMzCpAmpmZmZmZK0DNzMzMzMwoQDMzMzMzMyxAzczMzMzMKUDNzMzMzMwrQJqZmZmZmSxAZmZmZmZmKkBmZmZmZmYsQAAAAAAAACpAMzMzMzMzLUAzMzMzMzMqQGZmZmZmZi5A\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[126]},\"species\":[\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\",\"scandens\"],\"year\":[2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012,2012]},\"selected\":{\"id\":\"3669\"},\"selection_policy\":{\"id\":\"3687\"}},\"id\":\"3668\",\"type\":\"ColumnDataSource\"}],\"root_ids\":[\"3621\"]},\"title\":\"Bokeh Application\",\"version\":\"2.3.2\"}};\n",
" var render_items = [{\"docid\":\"2bd2da39-36dd-4438-be9c-611fea98dc1a\",\"root_ids\":[\"3621\"],\"roots\":{\"3621\":\"fb7f4e0b-cd9a-4cc6-978d-e4f4a368bf2b\"}}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" clearInterval(timer);\n",
" embed_document(root);\n",
" } else {\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" clearInterval(timer);\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
" }\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "3621"
}
},
"output_type": "display_data"
}
],
"source": [
"hv_fig = hv.Points(\n",
" data=df,\n",
" kdims=['beak length (mm)', 'beak depth (mm)'],\n",
" vdims=['species', 'year'],\n",
").groupby(\n",
" ['species', 'year'],\n",
").opts(\n",
" tools=['hover'],\n",
" show_legend=False,\n",
").overlay(\n",
" 'species',\n",
")\n",
"\n",
"# Take out the Bokeh object\n",
"p = hv.render(hv_fig)\n",
"\n",
"# Display using Bokeh\n",
"bokeh.io.show(p)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that we got the plot for 1973, which was the first year offered by the interactive HoloMap. If we wanted another year, we would have to make a plot specifically for that year."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Other kinds of plots\n",
"\n",
"We have seen the basics of how HoloViews works for a scatter plot specified by `hv.Points`. We now show some other kinds of plots we have encountered until now."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Smooth function\n",
"\n",
"HoloViews can plot a smooth function using the `hv.Curve`. For a Curve, there is one key dimension, which is the independent variable, and one value dimension, which is the dependent variable. This is to be contrasted with `hv.Path`, which has two key dimensions, meaning that neither of the variables is strictly dependent on the other.\n",
"\n",
"Here is a HoloViews plot of the x-section of the Airy disk. We can either provide a data frame with columns, or we can provide a 2-tuple of NumPy arrays that serve as the dependent and independent variable, respectively."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":Curve [x] (normalized intensity)"
]
},
"execution_count": 14,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "3841"
}
},
"output_type": "execute_result"
}
],
"source": [
"# The x-values we want\n",
"x = np.linspace(-15, 15, 400)\n",
"\n",
"# The normalized intensity\n",
"norm_I = 4 * (scipy.special.j1(x) / x)**2\n",
"\n",
"hv.Curve(\n",
" data=(x, norm_I),\n",
" kdims='x',\n",
" vdims='normalized intensity'\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Box plot\n",
"\n",
"Box plots are made using `hv.BoxWhisker` elements. If multiple key dimensions are specified, nested categorical axes are automatically set up."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"BokehUserWarning: ColumnDataSource's columns must be of the same length. Current lengths: ('beak depth (mm)', 32), ('beak_depth_left_parenthesis_mm_right_parenthesis', 0), ('index', 32)\n"
]
},
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":BoxWhisker [species,year] (beak depth (mm))"
]
},
"execution_count": 15,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "3963"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.BoxWhisker(\n",
" data=df,\n",
" kdims=['species', 'year'],\n",
" vdims=['beak depth (mm)'],\n",
").opts(\n",
" box_color='species',\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Strip plots\n",
"\n",
"We use `hv.Scatter()` to generate strip plots. When we specify the `jitter` kwargs, we specify the width of the jitter.\n",
"\n",
"Note that nested categorical axes are currently (as of June 10, 2021) only supported for box, violin, and bar plots, as [per the docs](http://holoviews.org/user_guide/Customizing_Plots.html#Categorical-axes), but will eventually be supported for many more plot types, including `Scatter`, which are used to generate strip plots."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":NdLayout [species]\n",
" :Scatter [year_str] (beak depth (mm),species)"
]
},
"execution_count": 16,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "4213"
}
},
"output_type": "execute_result"
}
],
"source": [
"# Make the year column a string to can use as categorical\n",
"df['year_str'] = df['year'].astype(str)\n",
"\n",
"hv.Scatter(\n",
" data=df,\n",
" kdims=[('year_str', 'year')],\n",
" vdims=['beak depth (mm)', 'species'],\n",
").groupby(\n",
" 'species'\n",
").opts(\n",
" color='species',\n",
" jitter=0.4,\n",
" show_legend=False,\n",
" width=400,\n",
" height=250,\n",
").layout(\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Histograms\n",
"\n",
"When making a histogram, the values of the bin edges and counts must be computed beforehand using `np.histogram()`."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"edges, counts = np.histogram(df_2012['beak depth (mm)'], bins=int(np.sqrt(len(df_2012))))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We then can pass the bin edges and counts into `hv.Histogram()`."
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":Histogram [beak depth (mm)] (Frequency)"
]
},
"execution_count": 18,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "4622"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Histogram(\n",
" data=(edges, counts),\n",
" kdims='beak depth (mm)'\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ECDFs\n",
"\n",
"HoloViews does not have native support for ECDFs ([my fault](https://github.com/holoviz/holoviews/issues/3821); I'm the one who is supposed to add this), but we can create ECDFs in a data frame and use `hv.Scatter` to make a plot of an ECDF."
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"def ecdf_transform(data):\n",
" return data.rank(method=\"first\") / len(data)\n",
"\n",
"df_2012[\"beak depth ECDF\"] = df_2012.groupby(\"species\")[\n",
" \"beak depth (mm)\"\n",
"].transform(ecdf_transform).values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After supplying the y-values for the ECDF, we plot with `hv.Scatter`."
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.holoviews_exec.v0+json": "",
"text/html": [
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"
\n",
"
\n",
""
],
"text/plain": [
":NdOverlay [species]\n",
" :Scatter [beak depth (mm)] (beak depth ECDF,species)"
]
},
"execution_count": 20,
"metadata": {
"application/vnd.holoviews_exec.v0+json": {
"id": "4744"
}
},
"output_type": "execute_result"
}
],
"source": [
"hv.Scatter(\n",
" data=df_2012,\n",
" kdims='beak depth (mm)',\n",
" vdims=[('beak depth ECDF', 'ECDF'), 'species'],\n",
").groupby(\n",
" 'species'\n",
").overlay(\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Conclusions\n",
"\n",
"HoloViews is one of many high-level plotting libraries in Python. Others include [Altair](https://altair-viz.github.io), [Seaborn](https://seaborn.pydata.org), and [ggplot](http://ggplot.yhathq.com). There is a pretty complete list available from [PyViz](https://pyviz.org/tools.html). HoloViews is my personal favorite, though, because of easy rendering with Bokeh and clear logic connecting annotated data sets to graphics.\n",
"\n",
"We have only begun to scratch the surface of what HoloViews can do. You can explore [HoloViews's extensive documentation](http://holoviews.org/index.html) to check out more of its capabilities. \n",
"\n",
"In the next few lessons, we will explore dealing with overplotting and dashboarding, two powerful plotting techniques you may not have thought about that can be transformative for your research."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Computing environment"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"tags": [
"hide-input"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Python implementation: CPython\n",
"Python version : 3.8.10\n",
"IPython version : 7.22.0\n",
"\n",
"numpy : 1.20.2\n",
"scipy : 1.6.2\n",
"pandas : 1.2.4\n",
"bootcamp_utils: 0.0.6\n",
"bokeh : 2.3.2\n",
"holoviews : 1.14.4\n",
"jupyterlab : 3.0.14\n",
"\n"
]
}
],
"source": [
"%load_ext watermark\n",
"%watermark -v -p numpy,scipy,pandas,bootcamp_utils,bokeh,holoviews,jupyterlab"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}