首页
\
问答
\
使用matplotlib的频率直方图 - 如何摆脱阵列显示?(frequency histogram with matplotlib--how to get rid of the array display?)
使用matplotlib的频率直方图 - 如何摆脱阵列显示?(frequency histogram with matplotlib--how to get rid of the array display?)
我创建一个简单的频率直方图:
figure(figsize=(12,9)) ax=subplot(111) #Get rid of the border lines ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) #Axis label xlabel("Gross Earnings", fontsize=16) ylabel("Frequency (in thousands)", fontsize=16) #Limit the x range so we can see the distribution more closely xlim(0, 40000) #Ticks ax.get_xaxis().tick_bottom() ax.get_yaxis().tick_left() hist(earnings, weights=wgts, color="#3F5D7D", bins=100)
我得到了直方图,但我也得到了巨型阵列的收益和显示的wgts。 我怎么摆脱那些?
谢谢!
I creating a simple frequency histogram:
figure(figsize=(12,9)) ax=subplot(111) #Get rid of the border lines ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) #Axis label xlabel("Gross Earnings", fontsize=16) ylabel("Frequency (in thousands)", fontsize=16) #Limit the x range so we can see the distribution more closely xlim(0, 40000) #Ticks ax.get_xaxis().tick_bottom() ax.get_yaxis().tick_left() hist(earnings, weights=wgts, color="#3F5D7D", bins=100)
I get the histogram alright, but I also get the giant arrays earnings and wgts in display. How do I get rid of those?
Thanks!
原文:https://stackoverflow.com/questions/30263135
更新时间:2022-07-15 17:07
最满意答案
尝试这样的事情,您可能需要稍微更改代码以适合您,
在你的脚本部分:
$("#individual_name").autocomplete({ source : base_url+"controller_name/suggest_names", minLength : 1, select: function( event, ui ) { alert('id :'+ui.item.value) ; //document.location.href = base_url+"controller_name/search?keyword="+ui.item.value; do something or redirect }, success : function(resp){ //alert("auto"); }, error : function(){ alert("Oops, that didn't work. Please try again."); } });
在你的控制器中:
function suggest_names(){ print_r ( $this->model_name->suggest_names($_REQUEST['term']) ); }
在您的模型部分:
function suggest_names($term){ $data = array(); $term = strtolower( addslashes( trim( urldecode($term) ) ) ); $temp = $this->db->select('name as label, id as value')->like('name', $term, 'LEFT')->get('table_name')->result_array(); $data = json_encode($temp); //echo "<pre>";print_r($data);echo "</pre>";die; return $data; }
如果您遇到任何问题,请告诉我。 希望对你有效。
Try something like this, You may need to change the code slightly to suit you,
In your script part:
$("#individual_name").autocomplete({ source : base_url+"controller_name/suggest_names", minLength : 1, select: function( event, ui ) { alert('id :'+ui.item.value) ; //document.location.href = base_url+"controller_name/search?keyword="+ui.item.value; do something or redirect }, success : function(resp){ //alert("auto"); }, error : function(){ alert("Oops, that didn't work. Please try again."); } });
In your controller:
function suggest_names(){ print_r ( $this->model_name->suggest_names($_REQUEST['term']) ); }
In your model part:
function suggest_names($term){ $data = array(); $term = strtolower( addslashes( trim( urldecode($term) ) ) ); $temp = $this->db->select('name as label, id as value')->like('name', $term, 'LEFT')->get('table_name')->result_array(); $data = json_encode($temp); //echo "<pre>";print_r($data);echo "</pre>";die; return $data; }
Let me know if you face any problem. Hope it works for you.
相关问答
更多-
我认为以下查询将解决您的问题 public function getUserGroups($limit = null, $offset = NULL) //better use $limit=0,$offset=0 { $this->db->select("user_group_id, name"); $this->db->from($this->db->dbprefix . 'user_group'); $this->db->limit($limit, $offset); $this->db->order ...
-
搜索过滤器应该使用getElementsByClassName吗?(Should search filter make use of getElementsByClassName?)[2022-05-02]
您可以使用更多基于数据的方法(我的意思是,它们都是基于数据的...让我们说它更像是一个数据库)通过将数组保存在115条记录的JavaScript中。 所以你有一个平面文件数据库,实际上。 如果你的javascript技能对此有好处,它将有助于使用生成div而不是隐藏它们的方法 - 这将解决Campari提到的资源问题。 它实际上比您当前的解决方案更具可扩展性。 首先,您可以将阵列保存在单独的.js或.ini文档中,以便于维护。 You can use a more data-based approach ( ... -
关于搜索过滤器的建议(Suggestions on the search filter)[2024-01-27]
尝试这样的事情,您可能需要稍微更改代码以适合您, 在你的脚本部分: $("#individual_name").autocomplete({ source : base_url+"controller_name/suggest_names", minLength : 1, select: function( event, ui ) { alert('id :'+ui.item.value) ; //document.locat ... -
Android:ListView加载更多(OnScrollListener)搜索过滤器(Android: ListView Load more (OnScrollListener) Search Filter)[2023-12-27]
我认为这取决于你如何看待搜索功能。 例如,如果您想使其成为本地过滤器,那么显然它将仅过滤已加载的项目。 如果搜索是全局搜索,则它始终可以使用筛选的项重置当前显示的列表。 在全局搜索的情况下,您可以向用户提供一些视觉元素,他可以切换回核心列表。 I think that depends how you have thought of search functionality. For e.g if you want to make it a local filter then obviously it wil ... -
搜索过滤器for opencart(Search filter for opencart)[2022-08-08]
您可以查看搜索控制器和模板并提取与搜索相关的信息,而不是在同一页面上处理信息,而只是将其发布到当前搜索页面。 这应该限制您深入研究搜索代码并将您需要更改的内容集中到控制器和视图。 You could look at the search controller and template and extract the information relating to the search, then instead of processing the information on the same page s ... -
您可以通过将search.stress指定为具有所需值的其他输入字段的ng-model来向search添加过滤器。 使用单选按钮的示例
将OnQueryTextListener更改为OnQueryTextListener SearhView.OnQueryTextListener Change OnQueryTextListenerAdapter into OnQueryTextListener SearhView.OnQueryTextListener糟糕的搜索过滤器(Bad search filter)[2023-11-03]
事实上,您的搜索过滤器很糟糕。 | character用于在OR语句中将多个条件连接在一起。 例如,如果您想查找姓氏为“smith”,“jones”或“baker”的人,则可以使用此过滤器: (|(lastname=smith)(lastname=jones)(lastname=baker)) 但是,您的过滤器只有一个条件,因此没有任何内容 要加入的角色。 将您的过滤器更改为此,它应该工作: "(uid=" + username + "\*)" 顺便问一下,你想用反斜杠和星号做什么? 您在寻找用户名实际 ...1st在构造函数中创建branchArrayList的副本。 branchArrayList这样: - private ArrayListbranchCopy = new ArrayList<>; public BranchAdapter(ArrayList items) { branchArrayList = items; branchCopy.addAll(items); filter = new CustomFilt ... 您尚未说明您的版本,但您可以在PF 3.2之后使用filterEvent上的enter事件。 早期版本,您可以使用此JavaScript解决方法 You haven't stated your version, but you can use the enter event on filterEvent since PF 3.2. Earlier version , you can use this javascript workaround相关文章
更多- 关于 style="display:none" 得问题
- display控件格式化时间日期的问题?
- 报错说找不到abbrev这个方法,但Array有这个方法的吧?
- 使用频率最高的美语口语296句
- Ehcache BigMemory: 摆脱GC困扰
- Guava处理java byte类型工具类-Bytes类
- 微信公众号API测试——接口调用频率限制
- 左则导航鼠标滑过时显示详情的实现
- solr4.7开发实践 2——高亮显示
- android高仿微信UI点击头像显示大图片效果
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)