<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to modify x-axis labels to show bin centers? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/470707#M132416</link>
    <description>&lt;P&gt;I am trying to create a histogram plot, but I want to make the x-axis labels more readable. How do I go about doing this?&lt;/P&gt;
&lt;P&gt;Here is what I am doing:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;my search | bin field span 0.5 | chart count by field&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Here is an example of the x-axis when create the chart. Is there a way to force the x-axis to show single values for each bin (at the bin center)? Or even better, can I force the x-axis to place integer labels at their respective positions relative to my bins?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8390i91902675763A4109/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 21 Nov 2020 05:56:04 GMT</pubDate>
    <dc:creator>rtakatsuka</dc:creator>
    <dc:date>2020-11-21T05:56:04Z</dc:date>
    <item>
      <title>How to modify x-axis labels to show bin centers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/470707#M132416</link>
      <description>&lt;P&gt;I am trying to create a histogram plot, but I want to make the x-axis labels more readable. How do I go about doing this?&lt;/P&gt;
&lt;P&gt;Here is what I am doing:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;my search | bin field span 0.5 | chart count by field&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Here is an example of the x-axis when create the chart. Is there a way to force the x-axis to show single values for each bin (at the bin center)? Or even better, can I force the x-axis to place integer labels at their respective positions relative to my bins?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8390i91902675763A4109/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 05:56:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/470707#M132416</guid>
      <dc:creator>rtakatsuka</dc:creator>
      <dc:date>2020-11-21T05:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Modify x-axis labels to show bin centers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/470708#M132417</link>
      <description>&lt;P&gt;@rtakatsuka Please try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my search 
| bin field span 0.5 
| chart count by field
| eval field=replace(field,"^([^-]+)-(.*)","\1")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will retain the first part of the bin (before hyphen). If you need the second part of bin after hyphen, use &lt;CODE&gt;\2&lt;/CODE&gt; instead of &lt;CODE&gt;\1&lt;/CODE&gt; i.e. &lt;CODE&gt;| eval field=replace(field,"^([^-]+)-(.*)","\2")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Following is  a run anywhere example with cooked up sample data, based on the question:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=10 
| eval field=random(), field=substr(field,1,1), count=random(), count=substr(count,3) 
| bin field span=0.5
| chart sum(count) as count by field
| eval field=replace(field,"^([^-]+)-(.*)","\1")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Feb 2020 02:35:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/470708#M132417</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-02-12T02:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modify x-axis labels to show bin centers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/530281#M149828</link>
      <description>&lt;P&gt;This works for positive numbers, but what about negative numbers? do we need to have some conditions for this case?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 01:20:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-modify-x-axis-labels-to-show-bin-centers/m-p/530281#M149828</guid>
      <dc:creator>Splunknewbuiee</dc:creator>
      <dc:date>2020-11-21T01:20:49Z</dc:date>
    </item>
  </channel>
</rss>

